States and Selectors - Template

If the module has different states and selectors you can divide them in subpages.

Show the path of the files that are in the module using code block.

For example, the transactions' state and selectors are in the transactionsSlice.ts and transactionsThunk.ts which are in the transactions redux folder and are shown below:

|-/redux
    |
    |-/transactions
        |- index.ts
        |- transactionsSlice.ts
        |- transactionsThunks.ts

Using expandable, add the initial state and selectors that make up the module.

Initial State

Add the initial state on a code block like shown in the example below. Make sure you add the file name at the top.

transactionsSlice.ts
initialState: SliceState = {
  transactionsState: { 
    total_count: 0,
    limit: 0,
    offset: 0,
    transactions: [],
  },
    
  isLoadingTransactions: false,
};
Selectors

List the selectors and describe them like the examples shown below:

  • getIsLoadingTransactions: This selector helps to know the transactions request state when the request is pending it is true and it helps to give feedback enabling a spinner in transactions component.

  • getTransactions: This selector gets transactions collection from the app state requested previously.

Explain how to fetch the data using examples, list the parameters if needed and describe them.

For example:

Last updated