frintjs / frint

Modular JavaScript framework for building scalable and reactive applications
https://frint.js.org/
MIT License
756 stars 37 forks source link

Support `render` prop in Route component of frint-router-react #302

Closed fahad19 closed 7 years ago

fahad19 commented 7 years ago

Currently, we only support passing Components like this:

<Route component={Foo} />

It is a requirement to also be able to pass props during render time like this:

const bar = {};

<Route
  path="/foo"
  exact
  component={routeProps => (
    <Foo
      bar={bar} // pass bar to <Foo> on route match
      {...routeProps}
    />
  )}
/>

Re-using the component prop for stateless components like above example means React would unmount and mount the component again, which is not a desired output.

So I suggest having a new prop, and call it render, that would take care of accepting stateless components and rendering them directly:

<Route render={() => <p>Hello world</p>} />