File tree Expand file tree Collapse file tree 2 files changed +7
-4
lines changed Expand file tree Collapse file tree 2 files changed +7
-4
lines changed Original file line number Diff line number Diff line change 1
1
# Change Log
2
2
3
3
## [ Unreleased]
4
+ ### Changed
5
+ - No useLayoutEffect for invoking listeners (which leads de-opt sync mode)
4
6
5
7
## [ 0.2.0] - 2019-07-07
6
8
### Changed
Original file line number Diff line number Diff line change @@ -12,9 +12,11 @@ const identity = x => x;
12
12
const CONTEXT_LISTENERS = Symbol ( 'CONTEXT_LISTENERS' ) ;
13
13
14
14
const createProvider = ( OrigProvider , listeners ) => React . memo ( ( { value, children } ) => {
15
- React . useLayoutEffect ( ( ) => {
16
- listeners . forEach ( listener => listener ( value ) ) ;
17
- } , [ value ] ) ;
15
+ // we call listeners in render intentionally.
16
+ // listeners are not technically pure, but
17
+ // otherwise we can't get benefits from concurrent mode.
18
+ // we make sure to work with double or more invocation of listeners.
19
+ listeners . forEach ( listener => listener ( value ) ) ;
18
20
return React . createElement ( OrigProvider , { value } , children ) ;
19
21
} ) ;
20
22
@@ -56,7 +58,6 @@ export const useContextSelector = (context, selector) => {
56
58
} catch ( e ) {
57
59
// ignored (stale props or some other reason)
58
60
}
59
- ref . current . value = nextValue ;
60
61
forceUpdate ( ) ;
61
62
} ;
62
63
listeners . add ( callback ) ;
You can’t perform that action at this time.
0 commit comments