Closed BlackFenix2 closed 4 years ago
Hello, thanks for the report. Would you mind opening a PR?
@troch i can fork the repo and investigate.
i found the culprit-ish, the useState and useReducers methods from reinspect are registered after the store is created in the StateInspector, hence the null @@INIT.
export const StateInspector: React.FC<StateInspectorProps> = ({
name,
initialState = {},
children
}) => {
const store: EnhancedStore = createStore(
storeReducer,
initialState,
window.__REDUX_DEVTOOLS_EXTENSION__({
name: name || "React state",
actionsBlacklist: ["/_init", "/_teardown"]
})
)
if i set the initialState on the StateInspector HOC that state is stored on the @@INIT Stange
const initialState = {
whereIsTheState: "Over here!"
}
function App() {
return (
<StateInspector name="Example" initialState={initialState}>
<Counters />
</StateInspector>
)
}
we would need to figure out a way to get the initialState from the useState and useReducer hooks into the HOC. I can work around this issue at work as-is but id like to see if we can do sometihng.
i opened a PR to add initialState to Redux Devtools without requiring a manual dispatch. we still have the empty @@INIT to worry about, unless we have discipline to not time-travel too far in the past (we don't). i can still investigate.
on the demo, the initialstate is not stored untill a single setState() or dispatch() function is invoked. if i use time travel debugging to go back to @@init the state tree goes null on the webpage