Skip to content
Merged
Changes from 1 commit
Commits
Show all changes
22 commits
Select commit Hold shift + click to select a range
9818f57
Initial proposal for async-friendly, static lifecycle hooks
bvaughn Dec 8, 2017
839547f
Added a note about the prefix
bvaughn Dec 8, 2017
b7189cc
Made deprecation/rename clearer
bvaughn Dec 8, 2017
aad6845
Hopefully clarified the computeMemoizeData() placeholder example
bvaughn Dec 8, 2017
99988da
Renamed example method for improved clarity
bvaughn Dec 9, 2017
4a34d25
Added note about aEL being unsafe in cWM
bvaughn Dec 9, 2017
902d4b3
Fixed typo
bvaughn Dec 9, 2017
3df7ce6
Fixing typo
bvaughn Dec 9, 2017
1864c93
Removed Facebook-specific terminology
bvaughn Dec 9, 2017
428758b
Tweaked wording for clarity
bvaughn Dec 9, 2017
cfcb7e8
Reorganization (part 1, more to come)
bvaughn Dec 9, 2017
536084d
Added some more focused examples
bvaughn Dec 9, 2017
a1431a4
Added a comment about calling setState on a possibly unmounted component
bvaughn Dec 9, 2017
3c6132e
Cancel async request on unmount in example
bvaughn Dec 9, 2017
4425dbe
Tweaking examples based on Dan's feedback
bvaughn Dec 9, 2017
67272ce
Renamed deriveStateFromProps to getDerivedStateFromNextProps
bvaughn Dec 13, 2017
c7f6728
Renamed prefetch to optimisticallyPrepareToRender
bvaughn Dec 13, 2017
bb2d246
Added `render` to a list
bvaughn Dec 14, 2017
8618f70
Removed static optimisticallyPrepareToRender() in favor of render()
bvaughn Dec 19, 2017
8f6c20e
Renamed getDerivedStateFromNextProps to getDerivedStateFromProps
bvaughn Jan 18, 2018
e05e317
Updated when getDerivedStateFromProps is called and what its argument…
bvaughn Jan 18, 2018
7042a2a
Renamed unsafe_* to UNSAFE_*
bvaughn Jan 18, 2018
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
Prev Previous commit
Renamed unsafe_* to UNSAFE_*
  • Loading branch information
bvaughn committed Jan 18, 2018
commit 7042a2abcbdc90b4a7784ea6a753ce9abac169d9
22 changes: 11 additions & 11 deletions text/0000-static-lifecycle-methods.md
Original file line number Diff line number Diff line change
Expand Up @@ -20,19 +20,19 @@ class ExampleComponent extends React.Component {
// Return null to indicate no change to state.
}

unsafe_componentWillMount() {
UNSAFE_componentWillMount() {
// New name for componentWillMount()
// Indicates that this method can be unsafe for async rendering.
// Prefer componentDidMount() instead.
}

unsafe_componentWillUpdate(nextProps, nextState) {
UNSAFE_componentWillUpdate(nextProps, nextState) {
// New name for componentWillUpdate()
// Indicates that this method can be unsafe for async rendering.
// Prefer componentDidUpdate() instead.
}

unsafe_componentWillReceiveProps(nextProps) {
UNSAFE_componentWillReceiveProps(nextProps) {
// New name for componentWillReceiveProps()
// Indicates that this method can be unsafe for async rendering.
// Prefer static getDerivedStateFromProps() instead.
Expand Down Expand Up @@ -369,21 +369,21 @@ Note that React may call this method even if the props have not changed. If calc

## Deprecated lifecycle methods

### `componentWillMount` -> `unsafe_componentWillMount`
### `componentWillMount` -> `UNSAFE_componentWillMount`

This method will log a deprecation warning in development mode recommending that users use `componentDidMount` instead (when possible) or rename to `unsafe_componentWillMount`.
This method will log a deprecation warning in development mode recommending that users use `componentDidMount` instead (when possible) or rename to `UNSAFE_componentWillMount`.

`componentWillMount` will be removed entirely in version 17.

### `componentWillUpdate` -> `unsafe_componentWillUpdate`
### `componentWillUpdate` -> `UNSAFE_componentWillUpdate`

This method will log a deprecation warning in development mode recommending that users use `componentDidUpdate` instead (when possible) or rename to `unsafe_componentWillUpdate`.
This method will log a deprecation warning in development mode recommending that users use `componentDidUpdate` instead (when possible) or rename to `UNSAFE_componentWillUpdate`.

`componentWillUpdate` will be removed entirely in version 17.

### `componentWillReceiveProps` -> `unsafe_componentWillReceiveProps`
### `componentWillReceiveProps` -> `UNSAFE_componentWillReceiveProps`

This method will log a deprecation warning in development mode recommending that users use the new static `getDerivedStateFromProps` method instead (when possible) or rename to `unsafe_componentWillReceiveProps`.
This method will log a deprecation warning in development mode recommending that users use the new static `getDerivedStateFromProps` method instead (when possible) or rename to `UNSAFE_componentWillReceiveProps`.

`componentWillReceiveProps` will be removed entirely in version 17.

Expand Down Expand Up @@ -411,9 +411,9 @@ There are no advanced proposals for such a stateful, functional component API th

Begin by reaching out to prominent third-party library maintainers to make sure there are no use-cases we have failed to consider.

Assuming we move forward with the proposal, release (at least one) minor 16.x update to add deprecation warnings for the legacy lifecycles and inform users to either rename with the `unsafe_` prefix or use the new static methods instead. We'll then cordinate with library authors to ensure they have enough time to migrate to the new API in advance of the major release that drops support for the legacy lifecycles.
Assuming we move forward with the proposal, release (at least one) minor 16.x update to add deprecation warnings for the legacy lifecycles and inform users to either rename with the `UNSAFE_` prefix or use the new static methods instead. We'll then cordinate with library authors to ensure they have enough time to migrate to the new API in advance of the major release that drops support for the legacy lifecycles.

We will provide a codemod to rename the deprecated lifecycle hooks with the new `unsafe_` prefix.
We will provide a codemod to rename the deprecated lifecycle hooks with the new `UNSAFE_` prefix.

We will also provide codemods to assist with the migration to static methods, although given the nature of the change, codemods will be insufficient to handle all cases. Manual verification will be required.

Expand Down