score:0
Accepted answer
second update:
change your render code in react/index.js
to
reactdom.render(
<router history={browserhistory} >
<route path="/" component={layout} >
<indexroute component={index} ></indexroute>
<route path="/exercise-1" name="exercise-1" component={exercise1} ></route>
<route path="/exercise-2" name="exercise-2" component={exercise2} ></route>
<route path="/exercise-3" name="exercise-3" component={exercise3} ></route>
<route path="/exercise-4" name="exercise-4" component={exercise4} ></route>
<route path="/exercise-5" name="exercise-5" component={exercise5} ></route>
<route path="/exercise-6" name="exercise-6" component={exercise6} ></route>
<route path="/:lessonname" name="lesson" component={lesson} ></route>
<route path=":lessonname" name="lesson" component={lesson} ></route>
</route>
</router>
,app);
i..e the path starts with /
score:1
this one worked for me
nb
for react router
use <browserrouter>
tag only once to enclose the whole of your application.
use this tag at the point of rendering.
for example
if you are using create-react-app
.use this at your index.js
file
reactdom.render(<browserrouter><app/></browserrouter>)
Source: stackoverflow.com
Related Query
- can't route successfully between components in react app
- React Router V4 - Route between components and not entire page
- Correct way to share functions between components in React
- What is the difference between NextJs and Create React App
- Error when deploying react app and it keeps sayings << Plugin "react" was conflicted between "package.json » eslint-config-react-app » >>
- Space between components in React Native styling
- Why does my React Native app build successfully despite TypeScript compiler error?
- Can we share code between react webapp and react native app and is react-native production ready
- React animate transition between components
- How to communicate UI state changes between React components with Redux?
- Cant load a react app after starting server
- Can a React app have components in different JS files without a build system?
- Switching between components in React JS
- how to share environment variables between react app and express js server hosting it as static site
- How to Fix Heroku Application Error For a Successfully Deployed React App
- What is the difference between arrow functions and regular functions inside React functional components (no longer using class components)?
- Components not re-rendering on route change - React HashRouter
- What is the difference between useHistory() and props.history in React Route
- Azure Static App Route configuration with React Router
- What is the simplest way to share react components between projects?
- React router app - Route title
- Media queries not working with styled components in React App
- Communication between two React form components with Redux
- Share the same styles between two types of component with React Styled Components
- how to deploy successfully React app with nextjs to AWS Amplify?
- pass state around between express middleware in an isomorphic react app
- How to share React Components between projects
- Ingress route - path based routing to different React app
- How to route in electron react app during production
- React router render prop route always re-renders components
More Query from same tag
- React: setState - which is more correct?
- redux toolkit state resets
- How to Access Variable Outside of Return in a Child from Parent?
- conditionally disable an option using react select not work when change option props passed to the Select
- ReactJS: Sort Option choices from API
- Browser Routers don`t render pages
- Map functions & continous rerendering with UseEffect
- Redux state variable is showing up as undefined
- How can I "mimic" a one to many relationship with react firebase cloud?
- Error: Request failed with status code 405
- React router dom v6 Auth
- React-Intl and JSON - Can I use multiple keys in one string?
- How do I use a dynamic JS library (wavesurfer.js) in a functional React component?
- Api not get pokemon names
- React - accessing a collection of objects
- How to access try catch error in Javascript through api request?
- Elegant ways of handling conditional rendering of multiple components
- Set acitve classname to multiple items in react js (map)
- How to dynamically import moment.js in a react app (with typescript)
- Should I test all component props?
- How to add colSpan in ReactJS styled components?
- Downsides of using two UI libraries in the same react project?
- How to mock AuthService service class used in component for testing?
- React component to be displayed as a summation of 2 ajax calls
- How to show an alert with errors found after submitting Formik form in react native
- Cypress: Not able to stub with a basic example. What might i be missing?
- POST request is working fine with postman but not in website
- React TS Variable is not updated in time
- Can I add optional attributes to an element in React?
- React setState only returning last item in a list saved to variable