1<Link to={{ pathname: "https://example.zendesk.com/hc/en-us/articles/123456789-Privacy-Policies" }} target="_blank" />
1import React, { Component } from 'react';
2import { render } from 'react-dom';
3import { BrowserRouter, Route, Switch, Link } from 'react-router-dom';
4import { Home } from 'wherever-you-put-it/home.component.jsx';
5import { Something } from 'wherever-you-put-it/something.component.jsx';
6import { SomethingElse } from 'wherever-you-put-it/something-else.component.jsx';
7
8class App extends Component {
9 render() {
10 return (
11 <BrowserRouter>
12 <Switch>
13 <Route path="/">
14 <Home />
15 </Route>
16 <Route path="/something">
17 <Something />
18 </Route>
19 <Route path="/somethingelse">
20 <SomethingElse />
21 </Route>
22 </Switch>
23 <SomeComponentOrElement>
24 <Link to="/">Home</Link>
25 <Link to="/something">Something</Link>
26 <Link to="/somethingelse">Something Else</Link>
27 </SomeComponentOrElement>
28 </BrowserRouter>
29 )
30 }
31}
32
33render(<App />, document.getElementById('app'));
1import React from "react";
2import ReactDOM from "react-dom";
3import {
4 BrowserRouter as Router,
5 Switch,
6 useLocation
7} from "react-router-dom";
8
9function usePageViews() {
10 let location = useLocation();
11 React.useEffect(() => {
12 ga.send(["pageview", location.pathname]);
13 }, [location]);
14}
15
16function App() {
17 usePageViews();
18 return <Switch>...</Switch>;
19}
20
21ReactDOM.render(
22 <Router>
23 <App />
24 </Router>,
25 node
26);
27
1import React from "react";
2import ReactDOM from "react-dom";
3import { Router } from "react-router";
4import { createBrowserHistory } from "history";
5
6const history = createBrowserHistory();
7
8ReactDOM.render(
9 <Router history={history}>
10 <App />
11 </Router>,
12 node
13);
14
1import React from "react";
2import ReactDOM from "react-dom";
3import { createBrowserHistory } from "history";
4
5const customHistory = createBrowserHistory();
6
7ReactDOM.render(<Router history={customHistory} />, node);
8