Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Remove useMutationEffect #14336

Merged
merged 1 commit into from
Nov 27, 2018
Merged

Remove useMutationEffect #14336

merged 1 commit into from
Nov 27, 2018

Conversation

sophiebits
Copy link
Collaborator

useMutationEffect has problems (namely, refs aren't attached at the time that it runs) and we're not positive it's necessary. useLayoutEffect runs at the same time as componentDidMount/Update so it's sufficient for all existing use cases; it can be used in any case that useEffect happens too late. Until we figure out what we want to do, let's delete it.

Copy link
Contributor

@bvaughn bvaughn left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Guess I'm going to need to update the Flow types again

@gaearon
Copy link
Collaborator

gaearon commented Nov 27, 2018

sorry @kentcdodds

@kentcdodds
Copy link

Haha, I'll update my blogpost :D

@sizebot
Copy link

sizebot commented Nov 27, 2018

ReactDOM: size: 0.0%, gzip: 0.0%

Details of bundled changes.

Comparing: 48f1e5b...708c60a

react-dom

File Filesize Diff Gzip Diff Prev Size Current Size Prev Gzip Current Gzip ENV
react-dom.development.js -0.0% 0.0% 718.54 KB 718.54 KB 166.31 KB 166.32 KB UMD_DEV
react-dom.production.min.js 0.0% 0.0% 97.79 KB 97.79 KB 31.84 KB 31.84 KB UMD_PROD
react-dom.profiling.min.js 0.0% 0.0% 100.68 KB 100.68 KB 32.52 KB 32.52 KB UMD_PROFILING
react-dom.development.js -0.0% 0.0% 713.86 KB 713.85 KB 164.94 KB 164.95 KB NODE_DEV
react-dom.profiling.min.js 0.0% 0.0% 100.78 KB 100.78 KB 31.97 KB 31.97 KB NODE_PROFILING
ReactDOM-dev.js -0.0% -0.0% 734.95 KB 734.87 KB 165.91 KB 165.9 KB FB_WWW_DEV
ReactDOM-prod.js -0.0% -0.0% 308.33 KB 308.18 KB 56.8 KB 56.77 KB FB_WWW_PROD
ReactDOM-profiling.js -0.0% -0.0% 315.12 KB 314.96 KB 58.18 KB 58.17 KB FB_WWW_PROFILING
react-dom-test-utils.development.js 0.0% 0.0% 44.87 KB 44.87 KB 12.3 KB 12.3 KB UMD_DEV
react-dom-test-utils.production.min.js 0.0% 0.0% 9.97 KB 9.97 KB 3.71 KB 3.71 KB UMD_PROD
react-dom-test-utils.development.js 0.0% 0.0% 44.59 KB 44.59 KB 12.24 KB 12.24 KB NODE_DEV
react-dom-test-utils.production.min.js 0.0% 0.0% 9.74 KB 9.74 KB 3.65 KB 3.65 KB NODE_PROD
react-dom-unstable-native-dependencies.development.js 0.0% 0.0% 60.61 KB 60.61 KB 15.92 KB 15.92 KB UMD_DEV
react-dom-unstable-native-dependencies.development.js 0.0% 0.0% 60.29 KB 60.29 KB 15.79 KB 15.79 KB NODE_DEV
react-dom-unstable-native-dependencies.production.min.js 0.0% -0.0% 10.75 KB 10.75 KB 3.71 KB 3.71 KB NODE_PROD
react-dom-server.browser.development.js -0.4% -0.1% 124.26 KB 123.82 KB 33.1 KB 33.07 KB UMD_DEV
react-dom-server.browser.development.js -0.4% -0.1% 120.39 KB 119.95 KB 32.17 KB 32.14 KB NODE_DEV
ReactDOMServer-dev.js -0.4% -0.1% 121.65 KB 121.18 KB 31.82 KB 31.79 KB FB_WWW_DEV
ReactDOMServer-prod.js -0.1% -0.1% 44.46 KB 44.42 KB 10.31 KB 10.3 KB FB_WWW_PROD
react-dom-server.node.development.js -0.4% -0.1% 122.45 KB 122.01 KB 32.71 KB 32.68 KB NODE_DEV
react-dom-server.node.production.min.js 0.0% 0.0% 17.77 KB 17.77 KB 6.83 KB 6.83 KB NODE_PROD

Generated by 🚫 dangerJS

useMutationEffect has problems (namely, refs aren't attached at the time that it runs) and we're not positive it's necessary. useLayoutEffect runs at the same time as componentDidMount/Update so it's sufficient for all existing use cases; it can be used in any case that useEffect happens too late. Until we figure out what we want to do, let's delete it.
@sophiebits sophiebits merged commit c2a2d8a into facebook:master Nov 27, 2018
sophiebits added a commit to sophiebits/react.dev that referenced this pull request Nov 27, 2018
diegohaz added a commit to diegohaz/constate that referenced this pull request Nov 28, 2018
BREAKING CHANGE: `useContextMutationEffect` has been removed. `React.useMutationEffect` will be removed from React hooks, so this is just to reflect that (see facebook/react#14336).
sophiebits added a commit to reactjs/react.dev that referenced this pull request Nov 28, 2018
@krave1986
Copy link

Maybe we can also update docs here. Code snippet explaining how to read an often-changing value from useCallback used this hook which is no longer available.

@sophiebits
Copy link
Collaborator Author

That exact link has already been updated.

facebook-github-bot pushed a commit to facebook/flow that referenced this pull request Nov 29, 2018
Summary:
Resolves #7219

- [x] 2fdcda5: Removed `React.useMutationEffect` hook (facebook/react/pull/14336) and updated tests. This hook was only ever exposed in an alpha release of 16.7 and so it should be safe to remove in a non-backwards-compatible way.
- [x] dabf49e: Add `React.Suspense` component and tests. (No final public documentation exists for `Suspense` yet– although we're working on it. For the time being, [tests like this](https://github.com/facebook/react/blob/master/packages/react-reconciler/src/__tests__/ReactSuspense-test.internal.js) can serve as a reference.)
- [x] 8df05bd: Fixed invalid `useCallback` definition and tests.
- [x] 063b022: Fixed invalid `React.lazy` signature to reflect that a `Promise` with a "default" property should be returned (rather than a React component).
Pull Request resolved: #7213

Reviewed By: jbrown215

Differential Revision: D13222880

Pulled By: bvaughn

fbshipit-source-id: 77e59e320698567c343c91a67b3aa91e9c925873
Jessidhia added a commit to Jessidhia/DefinitelyTyped that referenced this pull request Dec 3, 2018
Jessidhia added a commit to Jessidhia/DefinitelyTyped that referenced this pull request Dec 3, 2018
johnnyreilly pushed a commit to DefinitelyTyped/DefinitelyTyped that referenced this pull request Dec 3, 2018
gabelevi pushed a commit to facebook/flow that referenced this pull request Dec 4, 2018
Summary:
Resolves #7219

- [x] 2fdcda5: Removed `React.useMutationEffect` hook (facebook/react/pull/14336) and updated tests. This hook was only ever exposed in an alpha release of 16.7 and so it should be safe to remove in a non-backwards-compatible way.
- [x] dabf49e: Add `React.Suspense` component and tests. (No final public documentation exists for `Suspense` yet– although we're working on it. For the time being, [tests like this](https://github.com/facebook/react/blob/master/packages/react-reconciler/src/__tests__/ReactSuspense-test.internal.js) can serve as a reference.)
- [x] 8df05bd: Fixed invalid `useCallback` definition and tests.
- [x] 063b022: Fixed invalid `React.lazy` signature to reflect that a `Promise` with a "default" property should be returned (rather than a React component).
Pull Request resolved: #7213

Reviewed By: jbrown215

Differential Revision: D13222880

Pulled By: bvaughn

fbshipit-source-id: 9e1b48ace984051928c4ab92fa61182ad70f7119
yuchi added a commit to yuchi/hooks.macro that referenced this pull request Dec 18, 2018
Also, I was **not** testing for them, so...

Related: facebook/react#14336
@bvaughn
Copy link
Contributor

bvaughn commented Dec 31, 2018

After removing useMutationEffect, what should we do about this situation?
https://codesandbox.io/s/znx8kj1j0l

Someone asked the above question (but I guess it was deleted before I had a chance to respond?)

Anyway, in case someone else comes across this PR and wonders the same– it seemed worth re-emphasizing what Sophie said in the PR description:

useLayoutEffect runs at the same time as componentDidMount/Update so it's sufficient for all existing use cases; it can be used in any case that useEffect happens too late.

Updating the above repro to use useLayoutEffect instead will avoid the temporary flash of unstyled content. Here's an updated repro:
https://codesandbox.io/s/v6joo6k9o5

jetoneza pushed a commit to jetoneza/react that referenced this pull request Jan 23, 2019
useMutationEffect has problems (namely, refs aren't attached at the time that it runs) and we're not positive it's necessary. useLayoutEffect runs at the same time as componentDidMount/Update so it's sufficient for all existing use cases; it can be used in any case that useEffect happens too late. Until we figure out what we want to do, let's delete it.
n8schloss pushed a commit to n8schloss/react that referenced this pull request Jan 31, 2019
useMutationEffect has problems (namely, refs aren't attached at the time that it runs) and we're not positive it's necessary. useLayoutEffect runs at the same time as componentDidMount/Update so it's sufficient for all existing use cases; it can be used in any case that useEffect happens too late. Until we figure out what we want to do, let's delete it.
yesmeck added a commit to yesmeck/react-with-hooks that referenced this pull request Feb 3, 2019
OhIAmFine pushed a commit to OhIAmFine/zh-hans.reactjs.org that referenced this pull request May 6, 2019
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Projects
None yet
Development

Successfully merging this pull request may close these issues.

7 participants