There 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
This should work, no?
var Button = createReactClass({
statics: {
getDerivedStateFromProps() {
// ...
},
render() {
// ...
}
});
Note getDerivedStateFromProps is generally meant to be last resort and not recommended except a few edge cases.
What other methods did you have a problem with?
All the methods I was concerned about can be solved by your suggestion of using statics. I didn't see that in the documentation anywhere.
Yeah, doc needs updating. Filed https://github.com/reactjs/reactjs.org/issues/1214 for this — feel free to help.
You shouldn't need to put other methods in statics though. There are no other static methods in React component API.
There are some such as the name of component for Debugging purposes etc. I believe there is another too.
Most helpful comment
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?