[npm:create-react-class] No way to implement getDerivedStateFromProps
See original GitHub issueThere seems to be no way to implement class methods such as getDerivedStateFromProps and a few others.
Am I overlooking something?
There is no mention of it here either: https://reactjs.org/docs/react-without-es6.html
Issue Analytics
- State:
- Created 5 years ago
- Comments:5 (2 by maintainers)
Top Results From Across the Web
React.Component
This page contains a detailed API reference for the React component class definition. It assumes you're familiar with fundamental React concepts, ...
Read more >React.js static getDerivedStateFromProps() - GeeksforGeeks
React.js static getDerivedStateFromProps() · Step 1: Create a React application using the following command: npx create-react-app foldername.
Read more >create-react-class - npm
Start using create-react-class in your project by running `npm i ... There are 1713 other projects in the npm registry using create-react-class.
Read more >How to use lifecycle method getDerivedStateFromProps as ...
Below is an example I found online: State derived from props/state. Before class ExampleComponent extends React.Component { state = { ...
Read more >Class Components - React TypeScript Cheatsheets
Derived State can be implemented using hooks which can also help set up memoization. Here are a few ways in which you can...
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 Free
Top 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

This should work, no?
Note
getDerivedStateFromPropsis generally meant to be last resort and not recommended except a few edge cases.What other methods did you have a problem with?
See:
https://reactjs.org/docs/react-component.html#class-properties
https://github.com/facebook/react/blob/15-stable/addons/create-react-class/factory.js#L294