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

Confusing API of route.action #5

Closed
hikarino-my opened this issue Dec 9, 2020 · 1 comment
Closed

Confusing API of route.action #5

hikarino-my opened this issue Dec 9, 2020 · 1 comment

Comments

@hikarino-my
Copy link
Contributor

hikarino-my commented Dec 9, 2020

Current routing API as below is quite misleading, because React users think route.action accepts React Component, but actually doesn't.

const toplevelRoutes = Rocon.Path()
  .route("foo", (route) => route.action(() => <p>This is foo</p>));

Suggestion

there's several options to solve this.

  1. Add note to the Document on this page.
    AFAIK, this behavior isn't mentioned nor warned in the document.
    Or if it is, it should be more emphasized.
  2. Add another API that will accept React Component.
  3. Make route.action accept React Component
    I'm not sure these options are possible since this library is designed not only for React.
    Though adding some React friendly wrapper API that'll accept it and make React users use that API will be enough.
  4. Detect it is React Component or not before or during runtime before react warns it
    I don't think this is possible
@uhyo uhyo closed this as completed in 68ff9fc Feb 11, 2021
@uhyo
Copy link
Owner

uhyo commented Feb 11, 2021

@hikarinotomadoi
Thank you for reporting this!
We fixed this in v1.2.2. With that version, you can pass a React component as action.

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

No branches or pull requests

2 participants