cmdk icon indicating copy to clipboard operation
cmdk copied to clipboard

discussion: better way for 'routing'

Open ZhangHanwen96 opened this issue 1 year ago • 1 comments

I am just curious, and want to find a better way for routing, navigating between pages.

the example navigates on top level element:

activePage === 'xxx' && <Component1 />
activePage === 'xxxx' && <Component2 />
activePage === 'xxxxx' && <Component2 />

But as the command list grows bigger and nested command is used frequently, e.g.: 'home > projects > :projectID'

Does someone has a nicer way of doing this?

My solution with react-router-6

 <Routes location={`/<current-path>${location}`}> // "current-path refers to the path of the component that contains the current component as a child."
            <Route path="/home">
              <Route index element={<Home setPage={setPage} />}></Route>
              <Route path="prompts">
                <Route index element={<Prompts setPage={setPage} />}></Route>
                <Route path=":type" element={<div>type</div>}></Route>
              </Route>
              <Route path="projects" element={<Projects2 />} />
            </Route>
</Routes>

ZhangHanwen96 avatar May 04 '23 08:05 ZhangHanwen96

Hey @ZhangHanwen96, I made a small API to work with pages and breadcrumbs in cmdk. Hope it helps

joaom00 avatar May 09 '23 02:05 joaom00