0

I am using redux-toolkit in a vanilla js app and I'm having trouble understanding how to do something seemingly simple.

I'm a little overwhelmed with the redux-toolkit documentation, so I apologise if I have missed the answer there.

I have a master/details split view:

  • A table of 'items' in the top section
  • A tab list in the bottom section

Each tab shows details relating to the currently selected item.

Tab content needs to be updated when:

  • An item is selected in the table
  • A tab is selected

The data for each tab will come from an api call

My current itemsSlice implementation (with some code omitted for brevity):

const itemsAdapter = createEntityAdapter();
const itemsSlice = createSlice({
    name: 'items',
    initialState: itemsAdapter.getInitialState(),
    reducers: {
        itemSelected: (state, action) => {
            // state mutation omitted
        }
    },
    extraReducers: builder => { // api states omitted }
});

I think I should create a slice for each tab to manage it's state. But, how would I notify a tab slice that an item has been selected?

  • I believe this previous post answers my question: [https://stackoverflow.com/questions/67577835/same-action-triggering-in-multiple-slices-redux-toolkit](https://stackoverflow.com/questions/67577835/same-action-triggering-in-multiple-slices-redux-toolkit) – datahandler Mar 16 '23 at 07:10

0 Answers0