score:1
Accepted answer
Found the problem. In index.js I had React.StrictMode around my application. Removing it fixed the issue. I'm not sure exactly why that worked though.
score:0
index.js
import { BrowserRouter } from 'react-router-dom';
const defaultRender = () => {
ReactDOM.render(
<BrowserRouter>
<App />
</BrowserRouter>,
document.getElementById('root')
);
};
defaultRender();
App.js
import React from 'react';
import { Route, Switch } from 'react-router-dom';
import {Page1, Page2} from './pages';
const App = () => {
return (
<div className="App">
<Switch>
<Route exact path="/page1" component={Page1} />
<Route exact path="/page2" component={Page2} />
</Switch>
</div>
);
}
export default App;
Source: stackoverflow.com
Related Query
- React Router changes route but does not render the component
- React Router Link is not working. The Route changes but the component doesn't get rendered
- React Router Dom & Firebase Auth: history.push changes url but does not render new component when called after firebase auth create account
- React Router v5: history.push() changes the address bar, but does not change the page
- react router changes the URL, but the component is not rendered
- React router dom redirect problem. Changes url, does not render component
- React Router useHistory. History.push changes url but does not load component
- React URL changes but component does not render
- React router dom changes url, does not render component
- React Router Redirect does not render the component
- Clicking on link changes route but not Component itself - React Hook Router
- React router Link changes URL, but doesn't render the component
- Reactjs - changing url using react router but the component does not change
- URL changes but component is not render - React Router
- React router receives match params but does not update the component
- React router changes url but not the component [SOLVED]
- React Router DOM - Redirect component does not render route properly
- why react router url changes but component does not load in my nested router app
- React Router: Changes URL but does not render component
- React router changes the url but not reload the component
- React guard change the route but does not show the component
- React Router Link Not Rendering the Component but changes the URL
- How to pass the match when using render in Route component from react router (v4)
- How to fix React Router component not updating as route changes
- React router 4 `Link` component only changing the url and not updating the route
- React Router does not render Component
- React router changes url but not the view (only on Internet Explorer 11)
- React Router this.context.router.push does not remount the component
- React Link tag changes the url but doesnt render the component
- React Router "Link to" does not load new data when called from inside the same component
More Query from same tag
- react hook for setting the document title does not work on ssr
- Avoid duplication when using React Context
- Why isn't the state of Root component changing?
- React Component State modified before setState called
- How do I access the name of the city nested in this api response?
- Jest/Enzyme test React component with async/await method in try/catch
- Having trouble mapping json into React render
- useTransition - Object is not a function or its return value is not iterable
- reactjs setState doesn't change properly
- Type '(isOpen: boolean) => void' is not assignable to type 'boolean'. Error when using Modal in reactjs
- React: setTimeout not clearing within useEffect hook
- React component rendering twice when using useState hook
- How to best setup a click event when I have 3 different functions as possibilities
- Any idea why Typescript behaves this way with Material UI Alert severity prop?
- Can I have react-hooks/exhaustive-deps for a custom hook?
- Difference between a function and a stateless component?
- Dynamically loading react pages
- Access History object outside React component
- Nodemon and/or Hot Reloading with a Node-React Web App
- how to translate searchPlaceholder of MaterialTable reactjs using FormattedMessage
- Confusion with Argument of type '{ id: string; name: string; }[]' is not assignable to parameter of type 'SetStateAction<never[]>'
- meteor methods functions return is not working
- how to fix currentlyFocusedField is deprecated and will be removed in a future release. Use currentlyFocusedInput
- URL changing but view is not changing in React Router 4
- Next.js update state depending on router.asPath
- DOM Event doesn't working without arrow function
- Need help accessing state from useSelector, state disappears after rerender
- Accessing a url parameter to use in a query using react-router-relay
- Map Issue in React - this.state.Data.map is not a function
- ReferenceError: require is not defined (on my rest api)