State Management

Tools

Best Practices

  • On dynamic pages the url is the source of truth use the routerarrow-up-right when needed.

  • We prefer to use local state initially for component level state management.

  • We want to lift statearrow-up-right up the component tree as needed.

    • Use local context to avoid prop drilling. Put context as high in the component tree as needed.

    • Try not to default to always adding state to the redux store. Use redux only when sharing state across multiple places in the app. You can read more about the differences between context vs redux herearrow-up-right.

      • We use createSlicearrow-up-right from Redux Toolkit to create the actions and reducers.

      • We use createAsyncThunkarrow-up-right for async calls.

      • Everything in redux should be serializable. If there is anything that is stored inside of redux that CANNOT be serialized, it should not live inside of redux (ie, BigNumber).

    • We use React Hook Formarrow-up-right for form state management.

Note: If you have questions about any of these practices, please reach out to the core developement team.

Last updated

Was this helpful?