What will happen if you use props in initial state?
- It will cause a memory leak
- It will cause a runtime error
- It will ignore the props
- It will work as expected
Using props in initial state will cause the initial state to ignore the props. This is because the initial state is only set once, when the component is first created. If you want to use props to initialize state, you should set the state in the constructor instead.
Loading...