Fix set state calls
This branch consists of several changes to this.setState
calls. This could allow us to use PureComponent
instead of Component
which could result in improved performance.
Transformations include:
-
this.setState(prevState => {return {...}})
➡ this.setState(prevState => ({...}))
- Better ts types for
setState
related methods (usingkeyof Something
instead ofstring
) - increases type safety and prevents typos. - Using functional logic in react
setState
closures which is preferred in general (I would suggesting updatingtypescript
so thatsetState
callbacks can benefit of optional chaining i.e.prevState?.sections.map(a => ...)
instead ofprevState.sections ? prevState.sections.map(a => ...) : undefined
) - Removing unused parameters