File tree Expand file tree Collapse file tree 2 files changed +32
-0
lines changed
templates/react_typescript Expand file tree Collapse file tree 2 files changed +32
-0
lines changed Original file line number Diff line number Diff line change @@ -10,7 +10,9 @@ defmodule ComponentsGuideWeb.ReactTypescriptController do
10
10
@ articles % {
11
11
"testing" => % { title: "Testing React" } ,
12
12
"forms" => % { title: "Creating Forms in React" } ,
13
+ "state-levels" => % { title: "Levels of State in React" } ,
13
14
"reducer-patterns" => % { title: "React Reducer Patterns" } ,
15
+ "form-reducers" => % { title: "Form Validation with React Reducers" } ,
14
16
"zero-hook-dependencies" => % { title: "Zero Hook Dependencies" } ,
15
17
"hooks-concurrent-world" => % { title: "React Hooks in a Concurrent World" } ,
16
18
"logical-clocks" => % { title: "Logical Clocks in React" } ,
Original file line number Diff line number Diff line change
1
+ # React State
2
+
3
+ ## Derive local variable
4
+
5
+ ## useState
6
+
7
+ ## useReducer
8
+
9
+ ## useSyncExternalStore
10
+
11
+ ``` ts
12
+ function useIsOffline(): boolean {
13
+ const isOnline = useSyncExternalStore (
14
+ (callback : () => void ) => {
15
+ window .addEventListener (" offline" , callback );
16
+
17
+ return () => {
18
+ window .removeEventListener (" offline" , callback );
19
+ };
20
+ },
21
+ () => navigator .onLine ,
22
+ () => true
23
+ );
24
+ return ! isOnline ;
25
+ }
26
+ ```
27
+
28
+ ## Root prop
29
+
30
+ ## createContext
You can’t perform that action at this time.
0 commit comments