Support passing down state in `memoryLocation`.
Following the testing instructions about passing down memoryLocation(...).hook to Router I couldn't find a way to pass down state to the current location. The only args memoryLocation receives are:
path?: Path;
static?: boolean;
record: boolean;
It would be a very useful feature to let an additional prop be passed: state.
Hi @Grsz, it sounds like a nice feature to have! Adding a label to put it in a backlog, in the meantime feel free to open a pull-request.
I suppose the hook factory function can return a state object, the only caveat that it can't be destructured e.g.:
const { hook, state, navigate } = memoryLocation(...)
// state === {}
navigate("/", { state: { foo: "bar" } });
// state is still {}, so you have to use this instead
cost location = memoryLocation(...)
location.state //OK!
I think that it absolutely ok as long as we mention it in the docs.
shouldn't it be availble from useLocation? 🤔