React online documentation tutorials are uneven, I don't know which one should I learn? ?
Summarized the set I currently use
import React from 'react';
import './App.css';
import {
BrowserRouter, Route } from 'react-router-dom'
import A from './pages/A'
import Bottom from './pages/bottom'
import B from './pages/B'
function App() {
return (
<BrowserRouter>
<Route path="/A/:id" exact component={
A} />
<Route path="/B/:id" component={
B} />
<Bottom />
</BrowserRouter>
);
}
export default App;
router-dom'
BrowserRouter is the recommended history solution for applications using React-Router. It uses the History API in the browser for processing URLs, creating a real URL like example.com/list/123.
Where Route is the route path, and the called page component
How should sub-routes operate?
Let's go to path="/A/:id" to see
import React, {
Component } from 'react';
import {
Route } from "react-router-dom";
const User = ({
match }) => <p>{
match.params.id}</p>;
class A extends Component {
render() {
return (
<div>
<div>A</div>
<Route path="/A/:id" component={
User} />
</div>
)
}
}
export default A
For example, /A/cc means that cc that enters page A can use component to display which route to render.
After all, component={User} User is a variable.
I looked at it and thought, what did I say?
I always feel that react is too complicated. Compared with VUE's routing, it has high playability and I believe it is faster to improve js capabilities.
Then 1024 happy