score:0
change index.js to :
import react from 'react';
import reactdom from 'react-dom';
import app from './app';
reactdom.render(<app />, document.getelementbyid("root"));
change app.js to
import react, {useeffect} from 'react';
import reactdom from "react-dom";
import { browserrouter ,routes,route} from 'react-router-dom';
import forgetpassword from '.........'
import login from '.......'
function app(){
return(
<browserrouter>
<routes>
<route exact path="/" element={<login/>} />
<route path="/forgetpassword" element={<forgetpassword/>} />
<routes>
</browserrouter>
);
}
export default app;
if(document.getelementbyid('app')){
reactdom.render(<app/>,document.getelementbyid('app'));
}
score:0
if you are using react-router-dom version-6 then you can change your code as per the documentation https://github.com/remix-run/react-router/blob/main/docs/getting-started/tutorial.md
in index.js file
import { render } from "react-dom";
import { browserrouter } from "react-router-dom";
import app from "./app";
const rootelement = document.getelementbyid("root");
render(
<browserrouter>
<app />
</browserrouter>,
rootelement
);
in app.js file
import react, {useeffect} from 'react';
import { routes,route} from 'react-router-dom';
function app(){
return(
<routes>
<route path="/" element={<login/>}>
<route path="/forgetpassword" element={<forgetpassword/>}
<routes>
);
}
score:0
Source: stackoverflow.com
Related Query
- React.js URL changes but view does not change
- React router changes url but not view
- React Router v5: history.push() changes the address bar, but does not change the page
- React router changes url but not the view (only on Internet Explorer 11)
- React router does not change view, but url is changed - App is load inside iframe
- React Router useHistory. History.push changes url but does not load component
- React URL changes but component does not render
- React router goes to proper URL but does not update the view
- Link to changes state but does not change URL
- React router changes url but not loading view
- Reactjs - changing url using react router but the component does not change
- React Router Dom & Firebase Auth: history.push changes url but does not render new component when called after firebase auth create account
- history.push changes url but does not render form react hooks
- React state changes but background does not change
- why react router url changes but component does not load in my nested router app
- React Router Changes URL, but view does't change, but if i press enter when the url is on the browser tab it does
- React Router: Changes URL but does not render component
- React Link changes URL but does not render page
- React router 4 does not update view on link, but does on refresh
- React leaflet center attribute does not change when the center state changes
- react component state change after ajax call but does not rerender component
- onMouseDown event in react does not trigger state changes but onClick does
- URL changes but page new page is not rendered Ionic React , IonReactRouter with history
- URL changing but view is not changing in React Router 4
- React js Router changes url but not loading page
- URL change but page does not refresh
- react router changes url but not navigating to page
- REACT + REDUX: on redux state change mapStateToProps updating state but view is not rendering as per new state
- View wont update but the URL does in React Router V6
- React Router does not update component if url parameter changes
More Query from same tag
- managing multiple form variables using useState
- React.createElement: type should not be null, undefined, boolean, or number. It should be a string (for DOM elements)...; using fixed-data-table CDN
- changing width of a box inside map function in react js
- PropTypes giving error no matter if the type is right
- Frozen closure with useCallback/useMemo
- react router v4 redirecting to another page outside of component
- jest enzyme simulate('click') with event object and value
- Doing a router push in useEffect causes the effect to run in an infinite loop
- Not able to display fetched data on page, React JS
- handle swipe react JS
- Use of 'then' in ReactJS
- Data pushed in a json object erases when the page is refreshed
- Rendering a component using React Router and Redux crashing
- React Router: Render new view without page refresh
- Postgres UPDATE inserted value instead of all columns
- How to generate UUIDs in JS or React?
- REACT EDITED. trigger function from another component : TypeError: refreshmap is not a function
- Add To The Current Background Image Via JS?
- What is the best way to load and reuse api data for multiple routes in react
- Can I build 3D or 2D interactive games using React Native?
- Customize layout of AmplifySignOut
- How to display a div based on loggedin or not in react?
- Hooks can only be called inside the body of a function component error
- create-react-app is too slow and creates messy apps
- Getting an Error in my Manifest file on React App
- Adding Favicon.ico to Contentful or Gatsby website
- Element created in constructor not updated when component rerenders
- Cannot import firebase to React
- How to get an object with it's parent from firebase?
- Restoring previous state in Redux when going back in history with React-router