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
1010 @ articles % {
1111 "testing" => % { title: "Testing React" } ,
1212 "forms" => % { title: "Creating Forms in React" } ,
13+ "state-levels" => % { title: "Levels of State in React" } ,
1314 "reducer-patterns" => % { title: "React Reducer Patterns" } ,
15+ "form-reducers" => % { title: "Form Validation with React Reducers" } ,
1416 "zero-hook-dependencies" => % { title: "Zero Hook Dependencies" } ,
1517 "hooks-concurrent-world" => % { title: "React Hooks in a Concurrent World" } ,
1618 "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