Skip to content

Commit 8290732

Browse files
author
Brian Vaughn
committed
Merged master and resolved conflicts
2 parents 77f9b70 + af16f75 commit 8290732

File tree

69 files changed

+3227
-2952
lines changed

Some content is hidden

Large Commits have some content hidden by default. Use the searchbox below for content that may be hidden.

69 files changed

+3227
-2952
lines changed

.circleci/config.yml

Lines changed: 109 additions & 225 deletions
Large diffs are not rendered by default.

.codesandbox/ci.json

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1,6 +1,6 @@
11
{
22
"packages": ["packages/react", "packages/react-dom", "packages/scheduler"],
3-
"buildCommand": "build --type=NODE react/index,react-dom/index,react-dom/server,react-dom/test-utils,scheduler/index,scheduler/tracing",
3+
"buildCommand": "build --type=NODE react/index,react-dom/index,react-dom/server,react-dom/test-utils,scheduler/index,scheduler/unstable_no_dom,scheduler/tracing",
44
"publishDirectory": {
55
"react": "build/node_modules/react",
66
"react-dom": "build/node_modules/react-dom",

.gitignore

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -8,6 +8,7 @@ scripts/flow/*/.flowconfig
88
_SpecRunner.html
99
__benchmarks__
1010
build/
11+
build2/
1112
remote-repo/
1213
coverage/
1314
.module-cache

package.json

Lines changed: 2 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -106,7 +106,8 @@
106106
},
107107
"scripts": {
108108
"build": "node ./scripts/rollup/build.js",
109-
"build-for-devtools": "cross-env RELEASE_CHANNEL=experimental yarn build react/index,react-dom,react-is,react-debug-tools,scheduler,react-test-renderer,react-refresh",
109+
"build-combined": "node ./scripts/rollup/build-all-release-channels.js",
110+
"build-for-devtools": "cross-env RELEASE_CHANNEL=experimental yarn build-combined react/index,react-dom,react-is,react-debug-tools,scheduler,react-test-renderer,react-refresh",
110111
"build-for-devtools-dev": "yarn build-for-devtools --type=NODE_DEV",
111112
"build-for-devtools-prod": "yarn build-for-devtools --type=NODE_PROD",
112113
"linc": "node ./scripts/tasks/linc.js",

packages/eslint-plugin-react-hooks/__tests__/ESLintRuleExhaustiveDeps-test.js

Lines changed: 36 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -1692,6 +1692,42 @@ const tests = {
16921692
},
16931693
],
16941694
},
1695+
{
1696+
code: normalizeIndent`
1697+
function MyComponent() {
1698+
useEffect()
1699+
useLayoutEffect()
1700+
useCallback()
1701+
useMemo()
1702+
}
1703+
`,
1704+
errors: [
1705+
{
1706+
message:
1707+
'React Hook useEffect requires an effect callback. ' +
1708+
'Did you forget to pass a callback to the hook?',
1709+
suggestions: undefined,
1710+
},
1711+
{
1712+
message:
1713+
'React Hook useLayoutEffect requires an effect callback. ' +
1714+
'Did you forget to pass a callback to the hook?',
1715+
suggestions: undefined,
1716+
},
1717+
{
1718+
message:
1719+
'React Hook useCallback requires an effect callback. ' +
1720+
'Did you forget to pass a callback to the hook?',
1721+
suggestions: undefined,
1722+
},
1723+
{
1724+
message:
1725+
'React Hook useMemo requires an effect callback. ' +
1726+
'Did you forget to pass a callback to the hook?',
1727+
suggestions: undefined,
1728+
},
1729+
],
1730+
},
16951731
{
16961732
// Regression test
16971733
code: normalizeIndent`

packages/eslint-plugin-react-hooks/src/ExhaustiveDeps.js

Lines changed: 13 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -1119,6 +1119,19 @@ export default {
11191119
const declaredDependenciesNode = node.arguments[callbackIndex + 1];
11201120
const isEffect = /Effect($|[^a-z])/g.test(reactiveHookName);
11211121

1122+
// Check whether a callback is supplied. If there is no callback supplied
1123+
// then the hook will not work and React will throw a TypeError.
1124+
// So no need to check for dependency inclusion.
1125+
if (!callback) {
1126+
reportProblem({
1127+
node: reactiveHook,
1128+
message:
1129+
`React Hook ${reactiveHookName} requires an effect callback. ` +
1130+
`Did you forget to pass a callback to the hook?`,
1131+
});
1132+
return;
1133+
}
1134+
11221135
// Check the declared dependencies for this reactive hook. If there is no
11231136
// second argument then the reactive callback will re-run on every render.
11241137
// So no need to check for dependency inclusion.

packages/react-debug-tools/src/ReactDebugHooks.js

Lines changed: 15 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -73,6 +73,10 @@ function getPrimitiveStackCache(): Map<string, Array<any>> {
7373
Dispatcher.useState(null);
7474
Dispatcher.useReducer((s, a) => s, null);
7575
Dispatcher.useRef(null);
76+
if (typeof Dispatcher.useCacheRefresh === 'function') {
77+
// This type check is for Flow only.
78+
Dispatcher.useCacheRefresh();
79+
}
7680
Dispatcher.useLayoutEffect(() => {});
7781
Dispatcher.useEffect(() => {});
7882
Dispatcher.useImperativeHandle(undefined, () => null);
@@ -171,6 +175,16 @@ function useRef<T>(initialValue: T): {|current: T|} {
171175
return ref;
172176
}
173177

178+
function useCacheRefresh(): () => void {
179+
const hook = nextHook();
180+
hookLog.push({
181+
primitive: 'CacheRefresh',
182+
stackError: new Error(),
183+
value: hook !== null ? hook.memoizedState : function refresh() {},
184+
});
185+
return () => {};
186+
}
187+
174188
function useLayoutEffect(
175189
create: () => (() => void) | void,
176190
inputs: Array<mixed> | void | null,
@@ -305,6 +319,7 @@ function useOpaqueIdentifier(): OpaqueIDType | void {
305319
const Dispatcher: DispatcherType = {
306320
getCacheForType,
307321
readContext,
322+
useCacheRefresh,
308323
useCallback,
309324
useContext,
310325
useEffect,

0 commit comments

Comments
 (0)