-
Notifications
You must be signed in to change notification settings - Fork 1.2k
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
componentWillReceiveProps changes 1 #11233
componentWillReceiveProps changes 1 #11233
Conversation
@keybase/react-hackers this is part of of updating componentWillReceiveProps. There are a couple of patterns that are based on the blog post above. Sometimes the intention is to just make some state off of props. sometimes we want to make a call, etc |
note: i'm marking the folders stuff as unsafe as we're going to deprecate that whole section before any of this matters |
@keybase/react-hackers bump |
1 similar comment
@keybase/react-hackers bump |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Looks good! A couple comments. Also, do you know what this is about? (thrown on startup)
Warning: Unsafe legacy lifecycles will not be called for components using new component APIs.
ErrorBoundary uses getDerivedStateFromProps() but also contains the following legacy lifecycles:
componentWillReceiveProps
ErrorBoundary doesn't use componentWillReceiveProps
as far as I can tell. Does this mean that the deprecated lifecycles won't be called for any children?
componentWillReceiveProps(nextProps: Props) { | ||
if (nextProps.error !== this.props.error) { | ||
componentDidUpdate(prevProps: Props) { | ||
if (prevProps.error !== this.props.error) { | ||
this.props.setTimeout(() => { |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Can you store the timeoutIDs rather than _mounted
and clearTimeout
in componentWillUnmount
?
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
?
shared/teams/team/settings/index.js
Outdated
} | ||
} | ||
|
||
componentDidUpdate(prevProps: Props, prevState: State) { | ||
// We just got new settings for this team, reset any user selections |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
I think this comment belongs in getDerivedStateFromProps
now
they have a pr for hot loader: gaearon/react-hot-loader#927 |
@chrisnojima ok cool! |
… add return null from getDerived
@buoyad ptal |
… to desktop (#11232) * WIP * WIP * WIP * WIP * WIP * WIP * WIP * WIP * WIP * WIP * WIP * WIP * WIP * WIP * WIP * WIP * WIP * WIP * WIP * WIP * WIP * WIP * WIP * WIP * fix rn storybook * WIP * WIP * WIP * WIP * remove react infection in usertimings * Upgrade Electron to 1.8.4 (#11204) * bring back class properties * WIP * WIP * use componentDidMount vs willMount. Add StrictMode to desktop * componentWillReceiveProps changes 1 (#11233) * WIP * wip * WIP * WIP * remove strictmode. remove _mounted (already a hoc so its protected) . add return null from getDerived
Updating componentWillReceiveProps: More complicated than the didMount change.
See patterns here: https://reactjs.org/blog/2018/03/27/update-on-async-rendering.html