Description
What problem does this feature solve?
Mobile apps that want to save scroll position for elements besides window.
This would also allow the user to save whatever they want to history state. A project I'm working on now needs to keep track of what's "focused" per page and this seems like the correct place for it. It could also be a nice place for temporary form data. I'm sure there's a lot of use cases outside of this.
What does the proposed API look like?
I'm still thinking about it, though I think someone else thinking about it would be better. :)
I checked out react-router
a bit and it looks like we can make state part of the Location object, so we can set it in $router.push|replace({...})
or next({...})
calls. They use an additional argument but we might not need to?
I took a quick look at react-router and it seems to allow for this: https://github.com/ReactTraining/react-router/blob/master/packages/react-router/docs/api/history.md
Also, this seems to talk directly to the situation we're facing with scrolling:
https://reacttraining.com/react-router/web/guides/scroll-restoration
Also some additional reading: https://github.com/ReactTraining/history#properties
Hopefully this is useful and doesn't seem like useless rambling.