Ahmed Shahrour
1 min readJan 31, 2019

--

According to react docs

“In the event of an error, you can render a fallback UI with componentDidCatch() by calling setState, but this will be deprecated in a future release. Use static getDerivedStateFromError() to handle fallback rendering instead.”

I guess getDerivedStateFromError should be the defacto to change the state, in this case the “error”. Then handle logging in the componentDidCatch().

Thank you for the concise and to the point post.

Happy coding!

--

--

No responses yet