Skip to content

Commit

Permalink
Merged master and resolved conflicts
Browse files Browse the repository at this point in the history
  • Loading branch information
Brian Vaughn committed Jan 19, 2021
2 parents 77f9b70 + af16f75 commit 8290732
Show file tree
Hide file tree
Showing 69 changed files with 3,227 additions and 2,952 deletions.
334 changes: 109 additions & 225 deletions .circleci/config.yml

Large diffs are not rendered by default.

2 changes: 1 addition & 1 deletion .codesandbox/ci.json
Original file line number Diff line number Diff line change
@@ -1,6 +1,6 @@
{
"packages": ["packages/react", "packages/react-dom", "packages/scheduler"],
"buildCommand": "build --type=NODE react/index,react-dom/index,react-dom/server,react-dom/test-utils,scheduler/index,scheduler/tracing",
"buildCommand": "build --type=NODE react/index,react-dom/index,react-dom/server,react-dom/test-utils,scheduler/index,scheduler/unstable_no_dom,scheduler/tracing",
"publishDirectory": {
"react": "build/node_modules/react",
"react-dom": "build/node_modules/react-dom",
Expand Down
1 change: 1 addition & 0 deletions .gitignore
Original file line number Diff line number Diff line change
Expand Up @@ -8,6 +8,7 @@ scripts/flow/*/.flowconfig
_SpecRunner.html
__benchmarks__
build/
build2/
remote-repo/
coverage/
.module-cache
Expand Down
3 changes: 2 additions & 1 deletion package.json
Original file line number Diff line number Diff line change
Expand Up @@ -106,7 +106,8 @@
},
"scripts": {
"build": "node ./scripts/rollup/build.js",
"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",
"build-combined": "node ./scripts/rollup/build-all-release-channels.js",
"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",
"build-for-devtools-dev": "yarn build-for-devtools --type=NODE_DEV",
"build-for-devtools-prod": "yarn build-for-devtools --type=NODE_PROD",
"linc": "node ./scripts/tasks/linc.js",
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -1692,6 +1692,42 @@ const tests = {
},
],
},
{
code: normalizeIndent`
function MyComponent() {
useEffect()
useLayoutEffect()
useCallback()
useMemo()
}
`,
errors: [
{
message:
'React Hook useEffect requires an effect callback. ' +
'Did you forget to pass a callback to the hook?',
suggestions: undefined,
},
{
message:
'React Hook useLayoutEffect requires an effect callback. ' +
'Did you forget to pass a callback to the hook?',
suggestions: undefined,
},
{
message:
'React Hook useCallback requires an effect callback. ' +
'Did you forget to pass a callback to the hook?',
suggestions: undefined,
},
{
message:
'React Hook useMemo requires an effect callback. ' +
'Did you forget to pass a callback to the hook?',
suggestions: undefined,
},
],
},
{
// Regression test
code: normalizeIndent`
Expand Down
13 changes: 13 additions & 0 deletions packages/eslint-plugin-react-hooks/src/ExhaustiveDeps.js
Original file line number Diff line number Diff line change
Expand Up @@ -1119,6 +1119,19 @@ export default {
const declaredDependenciesNode = node.arguments[callbackIndex + 1];
const isEffect = /Effect($|[^a-z])/g.test(reactiveHookName);

// Check whether a callback is supplied. If there is no callback supplied
// then the hook will not work and React will throw a TypeError.
// So no need to check for dependency inclusion.
if (!callback) {
reportProblem({
node: reactiveHook,
message:
`React Hook ${reactiveHookName} requires an effect callback. ` +
`Did you forget to pass a callback to the hook?`,
});
return;
}

// Check the declared dependencies for this reactive hook. If there is no
// second argument then the reactive callback will re-run on every render.
// So no need to check for dependency inclusion.
Expand Down
15 changes: 15 additions & 0 deletions packages/react-debug-tools/src/ReactDebugHooks.js
Original file line number Diff line number Diff line change
Expand Up @@ -73,6 +73,10 @@ function getPrimitiveStackCache(): Map<string, Array<any>> {
Dispatcher.useState(null);
Dispatcher.useReducer((s, a) => s, null);
Dispatcher.useRef(null);
if (typeof Dispatcher.useCacheRefresh === 'function') {
// This type check is for Flow only.
Dispatcher.useCacheRefresh();
}
Dispatcher.useLayoutEffect(() => {});
Dispatcher.useEffect(() => {});
Dispatcher.useImperativeHandle(undefined, () => null);
Expand Down Expand Up @@ -171,6 +175,16 @@ function useRef<T>(initialValue: T): {|current: T|} {
return ref;
}

function useCacheRefresh(): () => void {
const hook = nextHook();
hookLog.push({
primitive: 'CacheRefresh',
stackError: new Error(),
value: hook !== null ? hook.memoizedState : function refresh() {},
});
return () => {};
}

function useLayoutEffect(
create: () => (() => void) | void,
inputs: Array<mixed> | void | null,
Expand Down Expand Up @@ -305,6 +319,7 @@ function useOpaqueIdentifier(): OpaqueIDType | void {
const Dispatcher: DispatcherType = {
getCacheForType,
readContext,
useCacheRefresh,
useCallback,
useContext,
useEffect,
Expand Down
Loading

0 comments on commit 8290732

Please sign in to comment.