Closed
Description
Continuing from #7 (comment), where @tbondwilkinson notes a sharp edge of the existing history.state
API:
history.pushState({ test: 2 }, null, '');
console.log(history.state.test); // 2
history.state.test = 3;
console.log(history.state.test); // 3
// refresh the page
console.log(history.state.test); // 2
That is, because it allows any arbitrary JavaScript object, it allows mutable JavaScript objects. But the object is only serialized into (semi-)persistent storage when you call history.pushState()
or history.replaceState()
.
The current proposal duplicates this sharp edge with app history state. E.g.,
appHistory.push({ state: { test: 2 } });
console.log(appHistory.current.state.test); // 2
appHistory.current.state.test = 3;
console.log(appHistory.current.state.test); // 3
// refresh the page
console.log(appHistory.current.state.test); // 2
This seems quite bad to me, and I think we should consider a way to fix it, if we can do so without interfering with other use cases. I'll post a reply with some suggestions.