Skip to content

Fix set state calls

Lukas Möller requested to merge new-fix-setState-calls into staging

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 (using keyof Something instead of string) - increases type safety and prevents typos.
  • Using functional logic in react setState closures which is preferred in general (I would suggesting updating typescript so that setState callbacks can benefit of optional chaining i.e. prevState?.sections.map(a => ...) instead of prevState.sections ? prevState.sections.map(a => ...) : undefined)
  • Removing unused parameters

Merge request reports

Loading