mirror of
https://github.com/openziti/zrok.git
synced 2025-01-09 07:28:15 +01:00
better react-router-dom idiom (#50)
This commit is contained in:
parent
539ffe78b5
commit
3a45ced9e1
@ -4,8 +4,10 @@ import Network from './Network';
|
|||||||
import Token from './Token';
|
import Token from './Token';
|
||||||
import Version from './Version';
|
import Version from './Version';
|
||||||
import { useEffect, useState } from 'react';
|
import { useEffect, useState } from 'react';
|
||||||
|
import { BrowserRouter as Router, Route, Routes } from 'react-router-dom';
|
||||||
|
import Register from "./Register";
|
||||||
|
|
||||||
const App = () => {
|
const Overview = () => {
|
||||||
const [user, setUser] = useState();
|
const [user, setUser] = useState();
|
||||||
|
|
||||||
useEffect(() => {
|
useEffect(() => {
|
||||||
@ -52,5 +54,16 @@ const App = () => {
|
|||||||
);
|
);
|
||||||
}
|
}
|
||||||
|
|
||||||
|
const App = () => {
|
||||||
|
return (
|
||||||
|
<Router>
|
||||||
|
<Routes>
|
||||||
|
<Route path={"/"} element={<Overview />}/>
|
||||||
|
<Route path={"register/:token"} element={<Register />} />
|
||||||
|
</Routes>
|
||||||
|
</Router>
|
||||||
|
);
|
||||||
|
}
|
||||||
|
|
||||||
export default App;
|
export default App;
|
||||||
|
|
||||||
|
@ -1,6 +1,13 @@
|
|||||||
|
import { useParams } from 'react-router-dom';
|
||||||
|
|
||||||
const Register = () => {
|
const Register = () => {
|
||||||
|
const { token } = useParams();
|
||||||
|
|
||||||
return (
|
return (
|
||||||
<h1>Register!</h1>
|
<div>
|
||||||
|
<h1>Register!</h1>
|
||||||
|
<p>token = "{token}"</p>
|
||||||
|
</div>
|
||||||
)
|
)
|
||||||
}
|
}
|
||||||
|
|
||||||
|
@ -1,26 +1,13 @@
|
|||||||
import React from 'react';
|
import React from 'react';
|
||||||
import ReactDOM from 'react-dom/client';
|
import ReactDOM from 'react-dom/client';
|
||||||
import './index.css';
|
import './index.css';
|
||||||
import App from './App';
|
|
||||||
import Register from "./Register";
|
|
||||||
import * as gateway from "./api/gateway";
|
import * as gateway from "./api/gateway";
|
||||||
import {createBrowserRouter, RouterProvider} from "react-router-dom";
|
import App from "./App";
|
||||||
|
|
||||||
const router = createBrowserRouter([
|
|
||||||
{
|
|
||||||
path: "/",
|
|
||||||
element: <App />,
|
|
||||||
},
|
|
||||||
{
|
|
||||||
path: "/register",
|
|
||||||
element: <Register />,
|
|
||||||
}
|
|
||||||
]);
|
|
||||||
|
|
||||||
const root = ReactDOM.createRoot(document.getElementById('root'));
|
const root = ReactDOM.createRoot(document.getElementById('root'));
|
||||||
root.render(
|
root.render(
|
||||||
<React.StrictMode>
|
<React.StrictMode>
|
||||||
<RouterProvider router={router} />
|
<App />
|
||||||
</React.StrictMode>
|
</React.StrictMode>
|
||||||
);
|
);
|
||||||
|
|
||||||
|
Loading…
Reference in New Issue
Block a user