@vimpak/jsx 0.2.0 → 0.3.0
This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
- package/README.md +19 -0
- package/package.json +1 -1
package/README.md
CHANGED
|
@@ -93,6 +93,21 @@ function App() {
|
|
|
93
93
|
const html = await render(<App />, ctx);
|
|
94
94
|
```
|
|
95
95
|
|
|
96
|
+
### Async Components
|
|
97
|
+
|
|
98
|
+
Components can be asynchronous:
|
|
99
|
+
|
|
100
|
+
```tsx
|
|
101
|
+
async function User({ id }: { id: string }) {
|
|
102
|
+
const user = await fetchUser(id);
|
|
103
|
+
return <div>{user.name}</div>;
|
|
104
|
+
}
|
|
105
|
+
|
|
106
|
+
const html = await render(<User id="1" />);
|
|
107
|
+
```
|
|
108
|
+
|
|
109
|
+
The `render` function awaits all async components automatically.
|
|
110
|
+
|
|
96
111
|
## API
|
|
97
112
|
|
|
98
113
|
### `render(element, context?)`
|
|
@@ -103,3 +118,7 @@ Renders a JSX element to an HTML string.
|
|
|
103
118
|
- **context** (optional): A `Context` value for passing values to all components
|
|
104
119
|
|
|
105
120
|
Returns `Promise<string>`.
|
|
121
|
+
|
|
122
|
+
## Thanks
|
|
123
|
+
|
|
124
|
+
- https://github.com/kitajs/html
|