Answers for "link react router"

4

link to react

import React, { Component } from 'react';
import { render } from 'react-dom';
import { BrowserRouter, Route, Switch, Link } from 'react-router-dom';
import { Home } from 'wherever-you-put-it/home.component.jsx';
import { Something } from 'wherever-you-put-it/something.component.jsx';
import { SomethingElse } from 'wherever-you-put-it/something-else.component.jsx';

class App extends Component {
	render() {
      return (
      	<BrowserRouter>
        	<Switch>
        		<Route path="/">
        			<Home />
        		</Route>
        		<Route path="/something">
        			<Something />
        		</Route>
        		<Route path="/somethingelse">
        			<SomethingElse />
        		</Route>
        	</Switch>
        	<SomeComponentOrElement>
        		<Link to="/">Home</Link>
        		<Link to="/something">Something</Link>
        		<Link to="/somethingelse">Something Else</Link>
        	</SomeComponentOrElement>
        </BrowserRouter>
      )
    }
}

render(<App />, document.getElementById('app'));
Posted by: Guest on April-16-2020
1

react router Link does work

import { Link } from 'react-router-dom';
Posted by: Guest on October-16-2020
1

react router link

import React from "react";
import ReactDOM from "react-dom";
import {
  BrowserRouter as Router,
  Switch,
  useLocation
} from "react-router-dom";

function usePageViews() {
  let location = useLocation();
  React.useEffect(() => {
    ga.send(["pageview", location.pathname]);
  }, [location]);
}

function App() {
  usePageViews();
  return <Switch>...</Switch>;
}

ReactDOM.render(
  <Router>
    <App />
  </Router>,
  node
);
Posted by: Guest on December-10-2020
1

link rezct

<Link
  to={{
    pathname: "/courses",
    search: "?sort=name",
    hash: "#the-hash",
    state: { fromDashboard: true }
  }}
/>
Posted by: Guest on June-18-2020
1

link react router dom

<Link
  to={{
    pathname: "/courses",
    search: "?sort=name",
    hash: "#https://api.alat.ng/RegistrationApi/index.html",
    state: { fromDashboard: true }
  }}
/>
Posted by: Guest on June-06-2021
1

react router link

import React from "react";
import ReactDOM from "react-dom";
import { Router } from "react-router";
import { createBrowserHistory } from "history";

const history = createBrowserHistory();

ReactDOM.render(
  <Router history={history}>
    <App />
  </Router>,
  node
);
Posted by: Guest on March-23-2021

Code answers related to "Javascript"

Browse Popular Code Answers by Language