There is a component down the line that uses hash but it's not re-rendering every time there is a change in the value of state.hash. How do I modify this code in reducer.js so that when state.hash is updated, the component that uses it is re-rendered from scratch?
import { createSlice } from "@reduxjs/toolkit";
const counterSlice = createSlice({
name: 'counter',
initialState: {
hash: null,
d: null,
},
reducers: {
update: (state, {payload}) => {
const {hash, d} = payload
state.hash = hash
state.d = d
}
}
})
export const {update} = counterSlice.actions
export const {reducer: counterReducer} = counterSlice
Alternatively, how do I change this code that calls the reducer to achieve the same effect?
store.dispatch(update({hash, d: d.toString()}))