mirror of
https://github.com/seigler/presentation-react-state-management
synced 2025-07-27 09:46:08 +00:00
Initial commit
This commit is contained in:
commit
98ab1bce45
9 changed files with 4868 additions and 0 deletions
17
src/error-page.tsx
Normal file
17
src/error-page.tsx
Normal file
|
@ -0,0 +1,17 @@
|
|||
import React from 'react'
|
||||
import { useRouteError } from 'react-router-dom'
|
||||
|
||||
export function ErrorPage() {
|
||||
const error = useRouteError()
|
||||
console.error(error)
|
||||
|
||||
return (
|
||||
<div id="error-page">
|
||||
<h1>Oops!</h1>
|
||||
<p>Sorry, an unexpected error has occurred.</p>
|
||||
<p>
|
||||
<i>{error.statusText || error.message}</i>
|
||||
</p>
|
||||
</div>
|
||||
)
|
||||
}
|
12
src/index.html
Normal file
12
src/index.html
Normal file
|
@ -0,0 +1,12 @@
|
|||
<!DOCTYPE html>
|
||||
<html lang="en">
|
||||
<head>
|
||||
<meta charset="utf-8" />
|
||||
<title>React State Management</title>
|
||||
<link rel="stylesheet" href="npm:simpledotcss/simple.min.css" />
|
||||
</head>
|
||||
<body>
|
||||
<div id="app"></div>
|
||||
<script type="module" src="index.tsx"></script>
|
||||
</body>
|
||||
</html>
|
21
src/index.tsx
Normal file
21
src/index.tsx
Normal file
|
@ -0,0 +1,21 @@
|
|||
import React from 'react'
|
||||
import ReactDOM from 'react-dom'
|
||||
import { createBrowserRouter, RouterProvider } from 'react-router-dom'
|
||||
import { ErrorPage } from './error-page'
|
||||
import { Root } from './routes/root'
|
||||
|
||||
const router = createBrowserRouter([
|
||||
{
|
||||
path: '/',
|
||||
element: <Root />,
|
||||
errorElement: <ErrorPage />
|
||||
}
|
||||
])
|
||||
|
||||
const appEntry = document.getElementById('app')
|
||||
ReactDOM.render(
|
||||
<React.StrictMode>
|
||||
<RouterProvider router={router} />
|
||||
</React.StrictMode>,
|
||||
appEntry
|
||||
)
|
5
src/routes/root.tsx
Normal file
5
src/routes/root.tsx
Normal file
|
@ -0,0 +1,5 @@
|
|||
import React from 'react'
|
||||
|
||||
export function Root() {
|
||||
return <h1>React State Management</h1>
|
||||
}
|
Loading…
Add table
Add a link
Reference in a new issue