Last active
January 26, 2019 06:57
-
-
Save tf/2dc63e72faf72f4cc44ebf261a3ddcc8 to your computer and use it in GitHub Desktop.
Revisions
-
tf revised this gist
Jan 26, 2019 . 1 changed file with 170 additions and 1 deletion.There are no files selected for viewing
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters. Learn more about bidirectional Unicode charactersOriginal file line number Diff line number Diff line change @@ -28,8 +28,56 @@ ### Time Slicing - Prevent blocking ``` * setState * start render * render yield | | * some other event handler | * render continue * render yield | | * some other event handler | * render continue * render finish ``` - Prioritized reconciling @@ -40,6 +88,34 @@ ``` * (low priority event) | * setState * start render * render yield | | * (high priority event) | | | * setState | * render start | | | * finish render | * re-apply state change * render ``` ### Suspense - Throwing Promises @@ -56,6 +132,42 @@ ``` * (event) | * setState * start render * render throw promise . . . * (event) . | . * setState . * render start . * finish render . . . . * promise resolve * re-aplly state change * render ``` ## Consequences - React is in charge of state @@ -107,7 +219,7 @@ ``` | REDUX STORE | * (low priority event) | { users: [] } @@ -128,6 +240,9 @@ x | cancel render | | | * finish render | ``` @@ -217,6 +332,25 @@ React managed state outside the component tree ``` const Context = React.createContext(defaultValue); function Component() { return ( <Context.Consumer> {value => /* render something ... */} </Context.Consumer> ); } ``` @@ -252,6 +386,38 @@ export function useStore() { ``` | Context | * (low priority event) | * { users: [] } | | | * dispatch | |\ * Context.write | * \ { users: [a,b,c] } * render start | | \ * render yield | | | | | | | | * (high priority event) | | | | | | | | | * dispatch | | | | * Context.write | | * { expanded: true, users: [] } | * render start | | / | * finish render | | / * | |/ * re-apply state changes | * { expanded: true, users: [a,b,c] } * render ``` Dependency Injection/Testing @@ -262,6 +428,9 @@ Dependency Injection/Testing ``` <Store.Provider value={...}> <TestedComponent /> -
tf revised this gist
Jan 26, 2019 . 1 changed file with 30 additions and 2 deletions.There are no files selected for viewing
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters. Learn more about bidirectional Unicode charactersOriginal file line number Diff line number Diff line change @@ -99,8 +99,36 @@ - Push vs Pull | REDUX STORE | * (low priority event) | { users: [] } | | * dispatch | * store change | { users: [a,b,c] } * Provider#setState | * render start | * render yield | | | | * (high priority event) | | | | | * dispatch | | * store change | { expanded: true, users: [a,b,c] } | * Provider#setState | | * render start | | | | x | cancel render | | | * finish render | -
tf revised this gist
Jan 26, 2019 . 1 changed file with 21 additions and 2 deletions.There are no files selected for viewing
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters. Learn more about bidirectional Unicode charactersOriginal file line number Diff line number Diff line change @@ -76,16 +76,35 @@ ## Redux - v5: Strore via Context - v6: State (and Store) via Context - Push vs Pull dispatch --> store change --> Provider#setState --> render ↓ -
tf revised this gist
Jan 25, 2019 . 1 changed file with 24 additions and 0 deletions.There are no files selected for viewing
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters. Learn more about bidirectional Unicode charactersOriginal file line number Diff line number Diff line change @@ -228,6 +228,30 @@ Dependency Injection/Testing ## Let Others Take Care of It - React Apollo - Unstated - Relay? ## Thanks! -
tf revised this gist
Jan 25, 2019 . 1 changed file with 12 additions and 3 deletions.There are no files selected for viewing
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters. Learn more about bidirectional Unicode charactersOriginal file line number Diff line number Diff line change @@ -46,8 +46,6 @@ - Placeholders - `maxDuration` @@ -91,6 +89,17 @@ Component State > Global State ## Caching External Data @@ -130,7 +139,7 @@ ### Global Singleton? - Risk of tearing -
tf revised this gist
Jan 25, 2019 . 1 changed file with 16 additions and 0 deletions.There are no files selected for viewing
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters. Learn more about bidirectional Unicode charactersOriginal file line number Diff line number Diff line change @@ -1,5 +1,21 @@ # Concurrent React, Redux and State Management ## Concurrent React -
tf revised this gist
Jan 25, 2019 . 1 changed file with 53 additions and 2 deletions.There are no files selected for viewing
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters. Learn more about bidirectional Unicode charactersOriginal file line number Diff line number Diff line change @@ -6,6 +6,10 @@ ### Time Slicing - Prevent blocking @@ -15,6 +19,11 @@ ### Suspense - Throwing Promises @@ -29,6 +38,10 @@ ## Consequences - React is in charge of state @@ -43,6 +56,10 @@ ## Redux - v5 vs v6 @@ -58,13 +75,17 @@ ## Caching External Data - Prevent re-fetching data - Take advantage of concurrent rendering mode @@ -77,9 +98,10 @@ ### Component State? - Data lost on unmount - Does not work with suspense @@ -88,6 +110,10 @@ ### Global singleton? - Risk of tearing @@ -98,6 +124,8 @@ ### `Context.write` https://github.com/reactjs/rfcs/pull/89 @@ -108,12 +136,18 @@ https://github.com/reactjs/rfcs/pull/89 React managed state outside the component tree ``` const Context = React.createContext(initialValue, contextDidUpdate); @@ -125,6 +159,9 @@ Context.write(prevValue => newValue); ``` const Store = React.createContext(initialState); @@ -141,11 +178,18 @@ export function useStore() { Dependency Injection/Testing ``` <Store.Provider value={...}> <TestedComponent /> @@ -155,6 +199,10 @@ Dependency Injection/Testing ## Thanks! @@ -170,6 +218,9 @@ www.codevise.de ## References https://www.youtube.com/watch?v=nLF0n9SACd4 -
tf revised this gist
Jan 25, 2019 . 1 changed file with 1 addition and 1 deletion.There are no files selected for viewing
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters. Learn more about bidirectional Unicode charactersOriginal file line number Diff line number Diff line change @@ -155,7 +155,7 @@ Dependency Injection/Testing ## Thanks! -
tf revised this gist
Jan 25, 2019 . 1 changed file with 21 additions and 0 deletions.There are no files selected for viewing
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters. Learn more about bidirectional Unicode charactersOriginal file line number Diff line number Diff line change @@ -114,6 +114,16 @@ React managed state outside the component tree ``` const Context = React.createContext(initialValue, contextDidUpdate); Context.write(newValue); Context.write(prevValue => newValue); ``` ``` const Store = React.createContext(initialState); @@ -131,6 +141,17 @@ export function useStore() { Dependency Injection/Testing ``` <Store.Provider value={...}> <TestedComponent /> </Store.Provider> ``` -
tf revised this gist
Jan 25, 2019 . 1 changed file with 1 addition and 1 deletion.There are no files selected for viewing
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters. Learn more about bidirectional Unicode charactersOriginal file line number Diff line number Diff line change @@ -67,7 +67,7 @@ - Prevent re-fetching data - Take advantage of concurrent rendering mode - Prevent tearing -
tf revised this gist
Jan 25, 2019 . 1 changed file with 67 additions and 15 deletions.There are no files selected for viewing
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters. Learn more about bidirectional Unicode charactersOriginal file line number Diff line number Diff line change @@ -4,6 +4,8 @@ ### Time Slicing - Prevent blocking @@ -15,23 +17,29 @@ ### Suspense - Throwing Promises - Placeholders - `lazy` - `maxDuration` ## Consequences - React is in charge of state - Ensures consistent state for tree across time slices (no "tearing") - "Work in progress" state @@ -44,44 +52,88 @@ ## Caching External Data - Prevent re-fetching data - Take advantage of of concurrent rendering mode - Prevent tearing ### Component State? - Data lost on unmount - Does not work with suspense ### Global singleton? - Risk of tearing ### `Context.write` https://github.com/reactjs/rfcs/pull/89 React managed state outside the component tree ``` const Store = React.createContext(initialState); export function dispatch(action) { Store.write(state => reducer(state, action)); } export function useStore() { return useContext(Store); } ``` Thanks! -
tf revised this gist
Jan 25, 2019 . 1 changed file with 23 additions and 4 deletions.There are no files selected for viewing
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters. Learn more about bidirectional Unicode charactersOriginal file line number Diff line number Diff line change @@ -1,10 +1,10 @@ # Concurrent React, Redux and State Management ## Concurrent React ### Time Slicing - Prevent blocking @@ -13,7 +13,7 @@ ### Suspense - Placeholders @@ -89,4 +89,23 @@ Thanks! github.com/tf @tfischbach www.codevise.de ## References https://www.youtube.com/watch?v=nLF0n9SACd4 https://blog.isquaredsoftware.com/2018/11/react-redux-history-implementation/ https://github.com/reduxjs/react-redux/issues/890 https://github.com/reduxjs/react-redux/pull/1000 https://github.com/reactjs/rfcs/pull/89 -
tf revised this gist
Jan 25, 2019 . 1 changed file with 39 additions and 13 deletions.There are no files selected for viewing
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters. Learn more about bidirectional Unicode charactersOriginal file line number Diff line number Diff line change @@ -1,56 +1,82 @@ # Concurrent React, Redux and State Management # Concurrent React ## Time Slicing - Prevent blocking - Prioritized reconciling ## Suspense - Placeholders - Throwing Promises - `lazy` - `maxDuration` ## Consequences - React is charge of state - Ensures consistent state for tree across time slices (no "tearing") - Work in progress state ## Redux - v5 vs v6 - Push vs Pull ## Global State? ### Why - Caching external data ### Goals - Outside of component tree - Compatible with async mode - ### Where - Component state? - Global singleton? - `Context.write` https://github.com/reactjs/rfcs/pull/89 -
tf revised this gist
Jan 25, 2019 . No changes.There are no files selected for viewing
-
tf created this gist
Jan 25, 2019 .There are no files selected for viewing
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters. Learn more about bidirectional Unicode charactersOriginal file line number Diff line number Diff line change @@ -0,0 +1,66 @@ # Concurrent React, Redux and State Management ## Concurrent React - Prevent blocking - Prioritized reconciling ## Suspense - Placeholders - Throwing Promises - `lazy` - `maxDuration` ## Consequences - React is charge of State ## Redux - Push vs Pull Thanks! github.com/tf @tfischbach www.codevise.de