-
-
Notifications
You must be signed in to change notification settings - Fork 10.2k
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
- Loading branch information
1 parent
6d79d3d
commit 2560422
Showing
4 changed files
with
53 additions
and
12 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,42 @@ | ||
--- | ||
"react-router": minor | ||
"react-router-dom": minor | ||
--- | ||
|
||
React Router now supports an alternative way to define your route `element` and `errorElement` fields as React Components instead of React Elements. You can instead pass a React Component to the new `Component` and `ErrorBoundary` fields if you choose. There is no functional difference between the two, so use whichever approach you prefer 😀. You shouldn't be defining both, but if you do `Component`/`ErrorBoundary` will "win". | ||
|
||
**Example JSON Syntax** | ||
|
||
```jsx | ||
// Both of these work the same: | ||
const elementRoutes = [{ | ||
path: '/', | ||
element: <Home />, | ||
errorElement: <HomeError />, | ||
}] | ||
|
||
const componentRoutes = [{ | ||
path: '/', | ||
Component: Home, | ||
ErrorBoundary: HomeError, | ||
}] | ||
|
||
function Home() { ... } | ||
function HomeError() { ... } | ||
``` | ||
|
||
**Example JSX Syntax** | ||
|
||
```jsx | ||
// Both of these work the same: | ||
const elementRoutes = createRoutesFromElements( | ||
<Route path='/' element={<Home />} errorElement={<HomeError /> } /> | ||
); | ||
|
||
const elementRoutes = createRoutesFromElements( | ||
<Route path='/' Component={Home} ErrorBoundary={HomeError} /> | ||
); | ||
|
||
function Home() { ... } | ||
function HomeError() { ... } | ||
``` |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters