Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Support passing down state in memoryLocation. #492

Open
Grsz opened this issue Oct 26, 2024 · 1 comment
Open

Support passing down state in memoryLocation. #492

Grsz opened this issue Oct 26, 2024 · 1 comment
Labels

Comments

@Grsz
Copy link

Grsz commented Oct 26, 2024

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.

@molefrog
Copy link
Owner

molefrog commented Nov 4, 2024

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.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
Projects
None yet
Development

No branches or pull requests

2 participants