You signed in with another tab or window. Reload to refresh your session.You signed out in another tab or window. Reload to refresh your session.You switched accounts on another tab or window. Reload to refresh your session.Dismiss alert
`useState` is a base API, It will receive initial state and return an Array
@@ -201,6 +209,49 @@ function App() {
201
209
return flag &&<span ref={t}>I will removed</span>
202
210
}
203
211
```
212
+
213
+
#### useContext
214
+
215
+
```js
216
+
import { createContext, useContext } from'react';
217
+
218
+
constThemeContext=createContext(null);
219
+
220
+
functionApp() {
221
+
return (
222
+
<ThemeContext.Provider value="dark">
223
+
<Button />
224
+
</ThemeContext.Provider>
225
+
)
226
+
}
227
+
228
+
functionButton({ children }) {
229
+
consttheme=useContext(ThemeContext);
230
+
constclassName='button-'+ theme;
231
+
return (
232
+
<button class={className}>
233
+
{children}
234
+
</button>
235
+
);
236
+
}
237
+
```
238
+
239
+
### Suspense
240
+
```js
241
+
constHello=lazy('./hello.js')
242
+
243
+
exportfunctionApp() {
244
+
return (
245
+
<div>
246
+
<Suspense fallback={<div>loading...</div>}>
247
+
<Hello />
248
+
<div>world!</div>
249
+
</Suspense>
250
+
</div>
251
+
)
252
+
}
253
+
```
254
+
204
255
### Fragments
205
256
206
257
```js
@@ -229,22 +280,6 @@ plugins: [
229
280
]
230
281
```
231
282
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.
0 commit comments