Skip to content

Commit

Permalink
Add documentation about suspense component to readme
Browse files Browse the repository at this point in the history
  • Loading branch information
i-like-robots committed Mar 8, 2024
1 parent 099f9ec commit c1129d7
Showing 1 changed file with 17 additions and 1 deletion.
18 changes: 17 additions & 1 deletion README.md
Original file line number Diff line number Diff line change
Expand Up @@ -35,7 +35,7 @@ $ npm install -S hyperons

This module provides two functions; one to create elements and one to render them. If you've worked with [React][react] or React-like libraries before then they're the equivalent to `React.createElement()` and `ReactDOM.renderToString()`.

The example below shows how to render a simple component using Hyperons:
The example below shows how to render a simple component using Hyperons with vanilla JavaScript:

[react]: https://reactjs.org/

Expand Down Expand Up @@ -129,6 +129,22 @@ const DescriptionList = () => {
}
```

### `Hyperons.Suspense`

`Suspense` is a special component which renders a fallback for lazy-loaded or async children. Hyperons only renders static HTML so this component exists only for compatibility purposes and will not render its children.

```jsx
import { h, Suspense } from 'hyperons'

const AsyncComponent = () => {
return (
<Suspense fallback={<Loading />}>
<SomeComponent />
</Suspense>
)
}
```

### `Hyperons.createContext`

Creates a new [context](#context) object. Components which subscribe to this context will read the current context value from the closest matching context provider above it in the tree. Hyperons largely supports the same [context API](https://reactjs.org/docs/context.html) as React including accessing context via the `Class.contextType` property and `useContext()` [hook](#hooks).
Expand Down

0 comments on commit c1129d7

Please sign in to comment.