Skip to content

[RFC] Add declarative components #1

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

Open
ramiel opened this issue Sep 21, 2019 · 0 comments
Open

[RFC] Add declarative components #1

ramiel opened this issue Sep 21, 2019 · 0 comments

Comments

@ramiel
Copy link
Owner

ramiel commented Sep 21, 2019

It would be useful to have declarative components. Those components:

  • Define a route entrypoint
  • Show any children if the current route matches
  • Accept, as props, anything a regular route would accept

Possible implementation

A component like that would be something similar to this

<RouterProvider>
   <RouteMatch path="/">
      <ChildComponent />
   </RouteMatch>

   <RouteMatch path="/user/:id">
      {
        (req, ctx) => <ChildComponent id={req.params.id} />
      }
   </RouteMatch>
</RouterProvider>

Question: should the children receive the req, ctx tuple or simply the parameters?

<RouteMatch path="/user/:id">
      {
        (props) => <ChildComponent id={props.id} />
      }
</RouteMatch>

A good reference could be the @reach/router Match implementation.

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

1 participant