Bug
Passing an id containing a forward slash (/) as the 4th argument to useReducer causes the returned state to be undefined, breaking any component that reads from it.
To reproduce
import { useReducer } from 'reinspect';
const [state, dispatch] = useReducer(reducer, initialState, undefined, 'MySlice/UpdateState');
console.log(state); // undefined
Expected behaviour
state should be the initial state (initialState), as it is when the id does not contain a /.
Actual behaviour
state is undefined, causing runtime errors in any component that accesses properties on it (e.g. Cannot read properties of undefined).
Workaround
Removing the / from the id fixes the issue:
const [state, dispatch] = useReducer(reducer, initialState, undefined, 'MySlice UpdateState');
Notes
The / character is used by Redux Toolkit as a namespace separator in action types (e.g. slice/action). It is likely that reinspect is parsing the id as a Redux action type and mishandling the namespace separator, resulting in the state not being correctly initialised.
Environment
- reinspect: 1.1.0
- React: 16
Bug
Passing an id containing a forward slash (
/) as the 4th argument touseReducercauses the returned state to beundefined, breaking any component that reads from it.To reproduce
Expected behaviour
stateshould be the initial state (initialState), as it is when the id does not contain a/.Actual behaviour
stateisundefined, causing runtime errors in any component that accesses properties on it (e.g.Cannot read properties of undefined).Workaround
Removing the
/from the id fixes the issue:Notes
The
/character is used by Redux Toolkit as a namespace separator in action types (e.g.slice/action). It is likely that reinspect is parsing the id as a Redux action type and mishandling the namespace separator, resulting in the state not being correctly initialised.Environment