question-mark
Stuck on an issue?

Lightrun Answers was designed to reduce the constant googling that comes with debugging 3rd party libraries. It collects links to all the places you might be looking at while hunting down a tough bug.

And, if you’re still stuck at the end, we’re happy to hop on a call to see how we can help out.

How to use getDerivedStateFromProps

See original GitHub issue

getDerivedStateFromProps is currently defined as member function without return, but should be a static function returning a state.

How do I use it?

Issue Analytics

  • State:closed
  • Created 5 years ago
  • Comments:7 (6 by maintainers)

github_iconTop GitHub Comments

1reaction
Hypnosphicommented, May 27, 2018

Looks like the above won’t work: Kotlin doesn’t attach companion object members directly to JS constructor. https://youtrack.jetbrains.com/issue/KT-18891 may help in the future, but for now you need to do it by hand:

MyComponent::Class.js.asDynamic().getDerivedStateFromProps = ...
0reactions
Leonyacommented, May 27, 2018

Added some documentation.

Read more comments on GitHub >

github_iconTop Results From Across the Web

React.js static getDerivedStateFromProps()
Step 1: Create a React application using the following command: npx create-react-app foldername · Step 2: After creating your project folder i.e. ...
Read more >
How to use lifecycle method getDerivedStateFromProps as ...
Change from componentWillReceiveProps to getDerivedStateFromProps. It's not breaking but forcing to refactor all existing code, which is very ...
Read more >
You Probably Don't Need Derived State
getDerivedStateFromProps exists for only one purpose. It enables a component to update its internal state as the result of changes in props. Our ......
Read more >
ReactJS – getDerivedStateFromProps() Method
In this example, we will build a React application which will fetch the list of users and on clicking the 'fetch user' button,...
Read more >
Lifecycle, state, getDerivedStateFromProps and Hooks
1. An instance of a component is created. 2. The component's UI is computed (rendering) and mounted into the DOM. 3. Then an...
Read more >

github_iconTop Related Medium Post

No results found

github_iconTop Related StackOverflow Question

No results found

github_iconTroubleshoot Live Code

Lightrun enables developers to add logs, metrics and snapshots to live code - no restarts or redeploys required.
Start Free

github_iconTop Related Reddit Thread

No results found

github_iconTop Related Hackernoon Post

No results found

github_iconTop Related Tweet

No results found

github_iconTop Related Dev.to Post

No results found

github_iconTop Related Hashnode Post

No results found