Skip to content

Commit

Permalink
fix(react): use Routes component wrapper for react router v6 (#9936)
Browse files Browse the repository at this point in the history
  • Loading branch information
juristr committed Apr 22, 2022
1 parent c1c5f0b commit fa1bc7b
Showing 1 changed file with 18 additions and 13 deletions.
31 changes: 18 additions & 13 deletions packages/react/src/utils/ast-utils.ts
Expand Up @@ -256,24 +256,29 @@ export function addInitialRoutes(
<li><Link to="/page-2">Page 2</Link></li>
</ul>
</div>
<Route
path="/"
element={
<div>This is the generated root route. <Link to="/page-2">Click here for page 2.</Link></div>
}
/>
<Route
path="/page-2"
element={
<div><Link to="/">Click here to go back to root page.</Link></div>
}
/>
<Routes>
<Route
path="/"
element={
<div>This is the generated root route. <Link to="/page-2">Click here for page 2.</Link></div>
}
/>
<Route
path="/page-2"
element={
<div><Link to="/">Click here to go back to root page.</Link></div>
}
/>
</Routes>
{/* END: routes */}
`,
};

return [
...addImport(source, `import { Route, Link } from 'react-router-dom';`),
...addImport(
source,
`import { Route, Routes, Link } from 'react-router-dom';`
),
insertRoutes,
];
}
Expand Down

0 comments on commit fa1bc7b

Please sign in to comment.