Decide what to do with upcoming react api changes
See original GitHub issueReact just published a blog post about upcoming api changes due to the planned suspense api. The current lifecycle methods will be deprecated with react v17.
We should decide if we want to follow them or leave the lifecycle methods as is. Note that our rendering process is currently not asynchronous but synchronous so we don’t have the same problems as them.
List of API changes recently introduced by react:
-
getDerivedStateFromProps
(#1094) -
getSnapshotBeforeUpdate
(#1112) -
componentDidCatch
(#819) -
Fragments
(#1080) -
new Context API
: currently no interest in bringing this into core (may change). preact-context is sort of a polyfill that can be used today -
UNSAFE_componentWill*
won’t be added to preact, simply continue usingcomponentWill*
hooks - ref-forwarding undecided, there hasn’t been any talk about this one yet
-
createRef
(#1138) -
createPortal
Issue Analytics
- State:
- Created 5 years ago
- Reactions:19
- Comments:22 (10 by maintainers)
Top Results From Across the Web
3 New API's In React 18 Every Developer Should Know
All you have to do is run npm install and install the latest versions of React and React DOM, and then there's one...
Read more >Everything You Need to Know about React Context in 2022 ...
This excerpt explores using React Context.Read it if you're a React developer or want to learn more about React.
Read more >Context
Changes are determined by comparing the new and old values using the same algorithm as Object.is . The way changes are determined can...
Read more >React 18: What You Need to Know and What's Changing
Due to the fact that React 18 introduces a new root API, you'll need to make one important change to take advantage of...
Read more >React 18 - What's New, What Changed & Upgrade Guide
React 18 was released and since it's a new major version, the big questions is: What changed ?Indeed, React 18 lays a solid...
Read more >Top Related Medium Post
No results found
Top Related StackOverflow Question
No results found
Troubleshoot Live Code
Lightrun enables developers to add logs, metrics and snapshots to live code - no restarts or redeploys required.
Start FreeTop Related Reddit Thread
No results found
Top Related Hackernoon Post
No results found
Top Related Tweet
No results found
Top Related Dev.to Post
No results found
Top Related Hashnode Post
No results found
Top GitHub Comments
We talked a bit on how we want to deal with the upcoming changes in yesterdays meeting. The general conclusion was to keep
componentWill*
hooks for now and add the new APIgetDerivedStateFromProps
andgetSnapshotBeforeUpdate
. We won’t add theUNSAFE_componentWill*
hooks like react did.The reasons for changing the api are outlined in the react announcement post or in the original getDerivedStateFromProps and getSnapshotBeforeUpdate rfcs. Note that some arguments made there don’t apply to preact because our rendering is synchronous. To summarise:
getDerivedStateFromProps
:props
orstate
Personally, I never thought that’d be an issue until I stumbled upon a component at work that mutated both state and props in
componentWillReceiveProps
. Moreover the author of that code was confused whycomponentWillReceiveProps
is not called when the component is constructed.getSnapshotBeforeUpdate
:static
in the initial RFC but later changed back to a normal methodcontext
argument likecomponentWillUpdate
.At this point I’m not sure if we need this for preact. Perhaps an alias is enough?
Opened PR #1094 for getDerivedStateFromProps