State Management

Tools

Best Practices

  • On dynamic pages the url is the source of truth use the router when needed.

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

  • We want to lift state 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 here.

      • We use createSlice from Redux Toolkit to create the actions and reducers.

      • We use createAsyncThunk 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 Form for form state management.

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

Last updated