GeezerVison is showing github.com — Remove unstable_changedBits (#20953) · react/react@6d3ecb7
File treeExpand file treeCollapse file tree Open diff view settings react-devtools-shared/src/devtools
Expand file treeCollapse file tree Open diff view settings Collapse file Copy file name to clipboardExpand all lines: packages/react-cache/src/ReactCacheOld.js +2-2Lines changed: 2 additions & 2 deletions | Original file line number | Diff line number | Diff line change |
|---|
@@ -46,7 +46,7 @@ const ReactCurrentDispatcher = | 46 | 46 | React.__SECRET_INTERNALS_DO_NOT_USE_OR_YOU_WILL_BE_FIRED | 47 | 47 | .ReactCurrentDispatcher; | 48 | 48 |
| 49 | | -function readContext(Context, observedBits) { | | 49 | +function readContext(Context) { | 50 | 50 | const dispatcher = ReactCurrentDispatcher.current; | 51 | 51 | if (dispatcher === null) { | 52 | 52 | throw new Error( | @@ -55,7 +55,7 @@ function readContext(Context, observedBits) { | 55 | 55 | 'lifecycle methods.', | 56 | 56 | ); | 57 | 57 | } | 58 | | - return dispatcher.readContext(Context, observedBits); | | 58 | + return dispatcher.readContext(Context); | 59 | 59 | } | 60 | 60 |
| 61 | 61 | function identityHashFn(input) { | |
Collapse file Copy file name to clipboardExpand all lines: packages/react-debug-tools/src/ReactDebugHooks.js +2-8Lines changed: 2 additions & 8 deletions | Original file line number | Diff line number | Diff line change |
|---|
@@ -109,18 +109,12 @@ function getCacheForType<T>(resourceType: () => T): T { | 109 | 109 | invariant(false, 'Not implemented.'); | 110 | 110 | } | 111 | 111 |
| 112 | | -function readContext<T>( | 113 | | - context: ReactContext<T>, | 114 | | - observedBits: void | number | boolean, | 115 | | -): T { | | 112 | +function readContext<T>(context: ReactContext<T>): T { | 116 | 113 | // For now we don't expose readContext usage in the hooks debugging info. | 117 | 114 | return context._currentValue; | 118 | 115 | } | 119 | 116 |
| 120 | | -function useContext<T>( | 121 | | - context: ReactContext<T>, | 122 | | - observedBits: void | number | boolean, | 123 | | -): T { | | 117 | +function useContext<T>(context: ReactContext<T>): T { | 124 | 118 | hookLog.push({ | 125 | 119 | primitive: 'Context', | 126 | 120 | stackError: new Error(), | |
Collapse file Copy file name to clipboardExpand all lines: packages/react-devtools-shared/src/devtools/cache.js +2-2Lines changed: 2 additions & 2 deletions | Original file line number | Diff line number | Diff line change |
|---|
@@ -61,7 +61,7 @@ const Rejected = 2; | 61 | 61 | const ReactCurrentDispatcher = (React: any) | 62 | 62 | .__SECRET_INTERNALS_DO_NOT_USE_OR_YOU_WILL_BE_FIRED.ReactCurrentDispatcher; | 63 | 63 |
| 64 | | -function readContext(Context, observedBits) { | | 64 | +function readContext(Context) { | 65 | 65 | const dispatcher = ReactCurrentDispatcher.current; | 66 | 66 | if (dispatcher === null) { | 67 | 67 | throw new Error( | @@ -70,7 +70,7 @@ function readContext(Context, observedBits) { | 70 | 70 | 'lifecycle methods.', | 71 | 71 | ); | 72 | 72 | } | 73 | | - return dispatcher.readContext(Context, observedBits); | | 73 | + return dispatcher.readContext(Context); | 74 | 74 | } | 75 | 75 |
| 76 | 76 | const CacheContext = createContext(null); | |
Collapse file Copy file name to clipboardExpand all lines: packages/react-dom/src/__tests__/ReactDOMServerIntegrationHooks-test.js +2-13Lines changed: 2 additions & 13 deletions | Original file line number | Diff line number | Diff line change |
|---|
@@ -736,17 +736,6 @@ describe('ReactDOMServerHooks', () => { | 736 | 736 | }, | 737 | 737 | ); | 738 | 738 |
| 739 | | - itRenders('warns when bitmask is passed to useContext', async render => { | 740 | | - const Context = React.createContext('Hi'); | 741 | | - | 742 | | - function Foo() { | 743 | | - return <span>{useContext(Context, 1)}</span>; | 744 | | - } | 745 | | - | 746 | | - const domNode = await render(<Foo />, 1); | 747 | | - expect(domNode.textContent).toBe('Hi'); | 748 | | - }); | 749 | | - | 750 | 739 | describe('useDebugValue', () => { | 751 | 740 | itRenders('is a noop', async render => { | 752 | 741 | function Counter(props) { | @@ -760,11 +749,11 @@ describe('ReactDOMServerHooks', () => { | 760 | 749 | }); | 761 | 750 |
| 762 | 751 | describe('readContext', () => { | 763 | | - function readContext(Context, observedBits) { | | 752 | + function readContext(Context) { | 764 | 753 | const dispatcher = | 765 | 754 | React.__SECRET_INTERNALS_DO_NOT_USE_OR_YOU_WILL_BE_FIRED | 766 | 755 | .ReactCurrentDispatcher.current; | 767 | | - return dispatcher.readContext(Context, observedBits); | | 756 | + return dispatcher.readContext(Context); | 768 | 757 | } | 769 | 758 |
| 770 | 759 | itRenders( | |
Collapse file Copy file name to clipboardExpand all lines: packages/react-dom/src/__tests__/ReactDOMServerIntegrationNewContext-test.js +2-2Lines changed: 2 additions & 2 deletions | Original file line number | Diff line number | Diff line change |
|---|
@@ -161,11 +161,11 @@ describe('ReactDOMServerIntegration', () => { | 161 | 161 | }); | 162 | 162 |
| 163 | 163 | itRenders('readContext() in different components', async render => { | 164 | | - function readContext(Ctx, observedBits) { | | 164 | + function readContext(Ctx) { | 165 | 165 | const dispatcher = | 166 | 166 | React.__SECRET_INTERNALS_DO_NOT_USE_OR_YOU_WILL_BE_FIRED | 167 | 167 | .ReactCurrentDispatcher.current; | 168 | | - return dispatcher.readContext(Ctx, observedBits); | | 168 | + return dispatcher.readContext(Ctx); | 169 | 169 | } | 170 | 170 |
| 171 | 171 | class Cls extends React.Component { | |
Collapse file Copy file name to clipboardExpand all lines: packages/react-dom/src/server/ReactPartialRendererHooks.js +2-8Lines changed: 2 additions & 8 deletions | Original file line number | Diff line number | Diff line change |
|---|
@@ -219,10 +219,7 @@ function getCacheForType<T>(resourceType: () => T): T { | 219 | 219 | invariant(false, 'Not implemented.'); | 220 | 220 | } | 221 | 221 |
| 222 | | -function readContext<T>( | 223 | | - context: ReactContext<T>, | 224 | | - observedBits: void | number | boolean, | 225 | | -): T { | | 222 | +function readContext<T>(context: ReactContext<T>): T { | 226 | 223 | const threadID = currentPartialRenderer.threadID; | 227 | 224 | validateContextBounds(context, threadID); | 228 | 225 | if (__DEV__) { | @@ -238,10 +235,7 @@ function readContext<T>( | 238 | 235 | return context[threadID]; | 239 | 236 | } | 240 | 237 |
| 241 | | -function useContext<T>( | 242 | | - context: ReactContext<T>, | 243 | | - observedBits: void | number | boolean, | 244 | | -): T { | | 238 | +function useContext<T>(context: ReactContext<T>): T { | 245 | 239 | if (__DEV__) { | 246 | 240 | currentHookNameInDev = 'useContext'; | 247 | 241 | } | |
Collapse file Copy file name to clipboardExpand all lines: packages/react-reconciler/src/ReactFiberBeginWork.new.js +6-23Lines changed: 6 additions & 23 deletions | Original file line number | Diff line number | Diff line change |
|---|
@@ -160,7 +160,6 @@ import { | 160 | 160 | checkIfContextChanged, | 161 | 161 | readContext, | 162 | 162 | prepareToReadContext, | 163 | | - calculateChangedBits, | 164 | 163 | scheduleWorkOnParentPath, | 165 | 164 | } from './ReactFiberNewContext.new'; | 166 | 165 | import {renderWithHooks, bailoutHooks} from './ReactFiberHooks.new'; | @@ -221,7 +220,7 @@ import { | 221 | 220 | restoreSpawnedCachePool, | 222 | 221 | getOffscreenDeferredCachePool, | 223 | 222 | } from './ReactFiberCacheComponent.new'; | 224 | | -import {MAX_SIGNED_31_BIT_INT} from './MaxInts'; | | 223 | +import is from 'shared/objectIs'; | 225 | 224 |
| 226 | 225 | import {disableLogs, reenableLogs} from 'shared/ConsolePatchingDev'; | 227 | 226 |
| @@ -795,12 +794,7 @@ function updateCacheComponent( | 795 | 794 | pushCacheProvider(workInProgress, nextCache); | 796 | 795 | if (nextCache !== prevState.cache) { | 797 | 796 | // This cache refreshed. Propagate a context change. | 798 | | - propagateContextChange( | 799 | | - workInProgress, | 800 | | - CacheContext, | 801 | | - MAX_SIGNED_31_BIT_INT, | 802 | | - renderLanes, | 803 | | - ); | | 797 | + propagateContextChange(workInProgress, CacheContext, renderLanes); | 804 | 798 | } | 805 | 799 | } | 806 | 800 | } | @@ -1169,12 +1163,7 @@ function updateHostRoot(current, workInProgress, renderLanes) { | 1169 | 1163 | pushCacheProvider(workInProgress, nextCache); | 1170 | 1164 | if (nextCache !== prevState.cache) { | 1171 | 1165 | // The root cache refreshed. | 1172 | | - propagateContextChange( | 1173 | | - workInProgress, | 1174 | | - CacheContext, | 1175 | | - MAX_SIGNED_31_BIT_INT, | 1176 | | - renderLanes, | 1177 | | - ); | | 1166 | + propagateContextChange(workInProgress, CacheContext, renderLanes); | 1178 | 1167 | } | 1179 | 1168 | } | 1180 | 1169 |
| @@ -3011,8 +3000,7 @@ function updateContextProvider( | 3011 | 3000 | } else { | 3012 | 3001 | if (oldProps !== null) { | 3013 | 3002 | const oldValue = oldProps.value; | 3014 | | - const changedBits = calculateChangedBits(context, newValue, oldValue); | 3015 | | - if (changedBits === 0) { | | 3003 | + if (is(oldValue, newValue)) { | 3016 | 3004 | // No change. Bailout early if children are the same. | 3017 | 3005 | if ( | 3018 | 3006 | oldProps.children === newProps.children && | @@ -3027,12 +3015,7 @@ function updateContextProvider( | 3027 | 3015 | } else { | 3028 | 3016 | // The context value changed. Search for matching consumers and schedule | 3029 | 3017 | // them to update. | 3030 | | - propagateContextChange( | 3031 | | - workInProgress, | 3032 | | - context, | 3033 | | - changedBits, | 3034 | | - renderLanes, | 3035 | | - ); | | 3018 | + propagateContextChange(workInProgress, context, renderLanes); | 3036 | 3019 | } | 3037 | 3020 | } | 3038 | 3021 | } | @@ -3090,7 +3073,7 @@ function updateContextConsumer( | 3090 | 3073 | } | 3091 | 3074 |
| 3092 | 3075 | prepareToReadContext(workInProgress, renderLanes); | 3093 | | - const newValue = readContext(context, newProps.unstable_observedBits); | | 3076 | + const newValue = readContext(context); | 3094 | 3077 | let newChildren; | 3095 | 3078 | if (__DEV__) { | 3096 | 3079 | ReactCurrentOwner.current = workInProgress; | |
Collapse file Copy file name to clipboardExpand all lines: packages/react-reconciler/src/ReactFiberBeginWork.old.js +6-23Lines changed: 6 additions & 23 deletions | Original file line number | Diff line number | Diff line change |
|---|
@@ -160,7 +160,6 @@ import { | 160 | 160 | checkIfContextChanged, | 161 | 161 | readContext, | 162 | 162 | prepareToReadContext, | 163 | | - calculateChangedBits, | 164 | 163 | scheduleWorkOnParentPath, | 165 | 164 | } from './ReactFiberNewContext.old'; | 166 | 165 | import {renderWithHooks, bailoutHooks} from './ReactFiberHooks.old'; | @@ -221,7 +220,7 @@ import { | 221 | 220 | restoreSpawnedCachePool, | 222 | 221 | getOffscreenDeferredCachePool, | 223 | 222 | } from './ReactFiberCacheComponent.old'; | 224 | | -import {MAX_SIGNED_31_BIT_INT} from './MaxInts'; | | 223 | +import is from 'shared/objectIs'; | 225 | 224 |
| 226 | 225 | import {disableLogs, reenableLogs} from 'shared/ConsolePatchingDev'; | 227 | 226 |
| @@ -795,12 +794,7 @@ function updateCacheComponent( | 795 | 794 | pushCacheProvider(workInProgress, nextCache); | 796 | 795 | if (nextCache !== prevState.cache) { | 797 | 796 | // This cache refreshed. Propagate a context change. | 798 | | - propagateContextChange( | 799 | | - workInProgress, | 800 | | - CacheContext, | 801 | | - MAX_SIGNED_31_BIT_INT, | 802 | | - renderLanes, | 803 | | - ); | | 797 | + propagateContextChange(workInProgress, CacheContext, renderLanes); | 804 | 798 | } | 805 | 799 | } | 806 | 800 | } | @@ -1169,12 +1163,7 @@ function updateHostRoot(current, workInProgress, renderLanes) { | 1169 | 1163 | pushCacheProvider(workInProgress, nextCache); | 1170 | 1164 | if (nextCache !== prevState.cache) { | 1171 | 1165 | // The root cache refreshed. | 1172 | | - propagateContextChange( | 1173 | | - workInProgress, | 1174 | | - CacheContext, | 1175 | | - MAX_SIGNED_31_BIT_INT, | 1176 | | - renderLanes, | 1177 | | - ); | | 1166 | + propagateContextChange(workInProgress, CacheContext, renderLanes); | 1178 | 1167 | } | 1179 | 1168 | } | 1180 | 1169 |
| @@ -3011,8 +3000,7 @@ function updateContextProvider( | 3011 | 3000 | } else { | 3012 | 3001 | if (oldProps !== null) { | 3013 | 3002 | const oldValue = oldProps.value; | 3014 | | - const changedBits = calculateChangedBits(context, newValue, oldValue); | 3015 | | - if (changedBits === 0) { | | 3003 | + if (is(oldValue, newValue)) { | 3016 | 3004 | // No change. Bailout early if children are the same. | 3017 | 3005 | if ( | 3018 | 3006 | oldProps.children === newProps.children && | @@ -3027,12 +3015,7 @@ function updateContextProvider( | 3027 | 3015 | } else { | 3028 | 3016 | // The context value changed. Search for matching consumers and schedule | 3029 | 3017 | // them to update. | 3030 | | - propagateContextChange( | 3031 | | - workInProgress, | 3032 | | - context, | 3033 | | - changedBits, | 3034 | | - renderLanes, | 3035 | | - ); | | 3018 | + propagateContextChange(workInProgress, context, renderLanes); | 3036 | 3019 | } | 3037 | 3020 | } | 3038 | 3021 | } | @@ -3090,7 +3073,7 @@ function updateContextConsumer( | 3090 | 3073 | } | 3091 | 3074 |
| 3092 | 3075 | prepareToReadContext(workInProgress, renderLanes); | 3093 | | - const newValue = readContext(context, newProps.unstable_observedBits); | | 3076 | + const newValue = readContext(context); | 3094 | 3077 | let newChildren; | 3095 | 3078 | if (__DEV__) { | 3096 | 3079 | ReactCurrentOwner.current = workInProgress; | |
Collapse file Copy file name to clipboardExpand all lines: packages/react-reconciler/src/ReactFiberCacheComponent.new.js -1Lines changed: 0 additions & 1 deletion | Original file line number | Diff line number | Diff line change |
|---|
@@ -37,7 +37,6 @@ export const CacheContext: ReactContext<Cache> = enableCache | 37 | 37 | // We don't use Consumer/Provider for Cache components. So we'll cheat. | 38 | 38 | Consumer: (null: any), | 39 | 39 | Provider: (null: any), | 40 | | - _calculateChangedBits: null, | 41 | 40 | // We'll initialize these at the root. | 42 | 41 | _currentValue: (null: any), | 43 | 42 | _currentValue2: (null: any), | |
Collapse file Copy file name to clipboardExpand all lines: packages/react-reconciler/src/ReactFiberCacheComponent.old.js -1Lines changed: 0 additions & 1 deletion | Original file line number | Diff line number | Diff line change |
|---|
@@ -37,7 +37,6 @@ export const CacheContext: ReactContext<Cache> = enableCache | 37 | 37 | // We don't use Consumer/Provider for Cache components. So we'll cheat. | 38 | 38 | Consumer: (null: any), | 39 | 39 | Provider: (null: any), | 40 | | - _calculateChangedBits: null, | 41 | 40 | // We'll initialize these at the root. | 42 | 41 | _currentValue: (null: any), | 43 | 42 | _currentValue2: (null: any), | |
|