Skip to content

Commit c7c8ae1

Browse files
committed
emmm
1 parent 039225f commit c7c8ae1

File tree

1 file changed

+51
-16
lines changed

1 file changed

+51
-16
lines changed

README.md

Lines changed: 51 additions & 16 deletions
Original file line numberDiff line numberDiff line change
@@ -45,6 +45,11 @@ function App() {
4545

4646
render(<App/>, document.body)
4747
```
48+
### Features
49+
50+
- [Suspense](https://github.com/yisar/fre#Suspense)
51+
52+
- [memo](https://github.com/yisar/fre#memo)
4853

4954
### Hooks API
5055

@@ -62,6 +67,9 @@ render(<App/>, document.body)
6267

6368
- [useRef](https://github.com/yisar/fre#useref)
6469

70+
- [useContext](https://github.com/yisar/fre#useContext)
71+
72+
6573
#### useState
6674

6775
`useState` is a base API, It will receive initial state and return an Array
@@ -201,6 +209,49 @@ function App() {
201209
return flag && <span ref={t}>I will removed</span>
202210
}
203211
```
212+
213+
#### useContext
214+
215+
```js
216+
import { createContext, useContext } from 'react';
217+
218+
const ThemeContext = createContext(null);
219+
220+
function App() {
221+
return (
222+
<ThemeContext.Provider value="dark">
223+
<Button />
224+
</ThemeContext.Provider>
225+
)
226+
}
227+
228+
function Button({ children }) {
229+
const theme = useContext(ThemeContext);
230+
const className = 'button-' + theme;
231+
return (
232+
<button class={className}>
233+
{children}
234+
</button>
235+
);
236+
}
237+
```
238+
239+
### Suspense
240+
```js
241+
const Hello = lazy('./hello.js')
242+
243+
export function App() {
244+
return (
245+
<div>
246+
<Suspense fallback={<div>loading...</div>}>
247+
<Hello />
248+
<div>world!</div>
249+
</Suspense>
250+
</div>
251+
)
252+
}
253+
```
254+
204255
### Fragments
205256

206257
```js
@@ -229,22 +280,6 @@ plugins: [
229280
]
230281
```
231282

232-
### Compare with other frameworks
233-
234-
The comparison is difficult because the roadmap and trade-offs of each framework are different, but we have to do so.
235-
236-
- react
237-
238-
React is the source of inspiration for fre. Their implementation and asynchronous rendering are similar. The most amazing thing is **concurrent mode**, which means that react and fre have the same roadmap -- **Exploring concurrent use cases**.
239-
240-
But at the same time, fre has obvious advantages in concurrent mode and bundle size.
241-
242-
- vue / preact
243-
244-
To some extent, vue and preact are similar. They have similar synchronous rendering, only the API is different.
245-
246-
The reconciliation algorithm of fre is similar to vue2, but the biggest difference is that vue/preact do not support concurrent mode, this means that the roadmap is totally different.
247-
248283
#### License
249284

250285
MIT @yisar

0 commit comments

Comments
 (0)