score:1
Accepted answer
one thing would be to use :
<route exact path="/" component={withapplayout(voting)} />
the exact will make sure that only that exact path is going to match. but if you have the path="/" after the others, the others should match first though. is this the real code you're using ?
edit: see a complete version below.
import {browserrouter, route, switch} from 'react-router-dom'
reactdom.render(
<browserrouter>
<switch>
<route exact path="/" component={voting} />
<route path="/results" component={results} />
</switch>
</browserrouter>,
document.getelementbyid('app')
);
then, if that works out, you can move the switch part into an app component. also, if you want to use hash history, you need to use a hashrouter that basically initializes a router with a hash history.
Source: stackoverflow.com
Related Query
- Conversion from React Router V2.x to V4.x
- How to redirect from axios interceptor with react Router V4?
- Accessing Redux Store from routes set up via React Router
- Moving from react router 3.x to 4.x
- How to pass the match when using render in Route component from react router (v4)
- React Router v4 Redirect Passing State from Search to Results
- redirect from redux action in react router v4
- ReactJS: Pass parameter from rails to react router to component
- React Router Warning: <Route> elements should not change from controlled to uncontrolled (or vice versa)
- Redirect React Router from Context Provider
- How to prevent react router from re-rendering a previously rendered page?
- get parameter value from url using React Router
- Passing props from react router to children on the server
- Getting error when try to use React Router v6: Attempted import error: 'Action' is not exported from 'history'
- React get props from Router with React Hooks
- How do I programaticly navigate to a route from an event handler in React Router 4.0?
- How to pass data from a page to another page using react router
- Going back from a redirect tag - React Router
- Why does React Router v6 seem unable to remove query string param from URL?
- React Router v4 Navigate from MobX store action?
- How to communicate from Child Component to Parent Component with React Router
- react router preload data from multiple components with a single loader animation
- How to hide a sidebar from a login page in react router
- React Router with RefluxJS - Changing route Programmatically from a Store
- React router animations. How to preserve components from unmounting during route transition
- I can not get the state from react router Link component using useLocation. So how can I pass it?
- Removing Hash from react router when using with Laravel
- Detect previous path in react router if i came from an outside application?
- Send props to react router component from parent layout component
- React Router "Link to" does not load new data when called from inside the same component
More Query from same tag
- React Virtualized Table - performance issues with input element in ~8 columns table
- Modify this yup validation to change max length to 9 if the string does not include a dash
- How to add a button in React Native?
- dynamic File inside folders not reading with React and preval.macro
- Is this the correct way for storing a sub-collection?
- Keep getting this error in javascript, error: column reference "id" is ambiguous
- Heroku + react + next.js + wordpress - Syntax error, but what do I do?
- Calling setstate on a parent component forces componentDidUpdate on its children?
- Why are my props not being passed into my component when mount rendering?
- How "history" object is getting evaluated in React
- Custom react-admin drag & drop list
- Can not get value of input in reactJS Typescript
- How to get the latest value from selected drop down
- How to update the global state using redux and remove an item from the global state
- call a component function from header componet in react router
- Certain object properties undefined in React component
- How to load script in react component
- How can I update the value from the database in React
- How to add event to react function and re-render function
- How to integrate Firebaseui auth with Redux
- Fading out a span with css animations leaves space
- Why does setState in this promise take longer to update than the same code as an async function?
- How to update Event.target after props.function in child component is dispatched to redux-thunk onClick
- Why is the output different with React setState()
- Getting “Cannot call a class as a function” in my React Project :throw new TypeError("Cannot call a class as a function");
- react axios getting values one by one
- accessing data from a nested Json
- How to add components to list dynamically in React with no redundant render?
- TypeError: _database_db_json__WEBPACK_IMPORTED_MODULE_2__.map is not a function
- How do I convert componentDidMount() and componentWillUnmount to the useEffect()?