Answers for "link component react router to"

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
0

how to link to a different component in reactjs without react router

const showComponent = (route, component) => {
  return window.location.pathname === route ? component : null
}
Posted by: Guest on November-28-2020

Code answers related to "Javascript"

Browse Popular Code Answers by Language