FormidableLabs / redux-little-router

A tiny router for Redux that lets the URL do the talking.
MIT License
1.04k stars 114 forks source link

RelativeFragment forRoutes #133

Open dpwrussell opened 7 years ago

dpwrussell commented 7 years ago

I think it would make sense if forRoutes was available on <RelativeFragment> as well as <AbsoluteFragment>.

Say you have <Book> React class that handles the rendering of most books (but encyclopedias have their own <Encyclopedia>), but your application subdivides these by genre. E.g.

/
  /login
  /books
    /crime/:isbn
    /fantasy/:isbn
    /cookery/:isbn
    /encyclopedia/:isbn

This is contrived, but what you want is to have:

      <RouterProvider store={ store }>
        <BookApp>

          <RelativeFragment forRoute='/login'>
            <Login />
          </RelativeFragment>

          <RelativeFragment forRoute='/books']>

            <RelativeFragment forRoutes=['/crime', '/fantasy', '/cookery']>
              <Book />
            </RelativeFragment>

            <RelativeFragment forRoute='/encyclopedia'>
              <Encyclopedia />
            </RelativeFragment>

          </RelativeFragment>

        </BookApp>
      </RouterProvider>
thj-dk commented 7 years ago

I'd like to see this as well.

tptee commented 7 years ago

I dig it! Will let y'all know when I'm working on this 👍