score:0
it works like following. please compare your solution. basically topmost route should have path as "/" for children "/" not required
<router history={apphistory}>
<route path="/" component={main}>
<route path="test" component={test}/>
<route path="*" component={test}/>
</route>
</router>
const main = ({children, history}) => {
return (
<div>
<nav>
<div history={history}/>
</nav>
<div>
{children}
</div>
</div>
)
}
Source: stackoverflow.com
Related Query
- Cannot read property push of undefined for react use history
- React - uncaught TypeError: Cannot read property 'setState' of undefined
- Line 0: Parsing error: Cannot read property 'map' of undefined
- react router v^4.0.0 Uncaught TypeError: Cannot read property 'location' of undefined
- Error : Cannot read property 'map' of undefined
- React with ES7: Uncaught TypeError: Cannot read property 'state' of undefined
- Uncaught TypeError: Cannot read property 'push' of undefined (React-Router-Dom)
- React enzyme testing, Cannot read property 'have' of undefined
- Cannot read property 'history' of undefined (useHistory hook of React Router 5)
- React - TypeError: Cannot read property 'props' of undefined
- React-Router - Uncaught TypeError: Cannot read property 'getCurrentLocation' of undefined
- Redux TypeError: Cannot read property 'apply' of undefined
- React Router: Cannot read property 'pathname' of undefined
- React Typescript: Line 0: Parsing error: Cannot read property 'name' of undefined
- reactjs Cannot read property 'keys' of undefined
- TypeError: Cannot read property 'contextTypes' of undefined
- TypeError when using React: Cannot read property 'firstChild' of undefined
- TypeError: Cannot read property 'prepareStyles' of undefined
- Cannot read property '.then' of undefined when testing async action creators with redux and react
- Cannot read property ‘params’ of undefined (React Router 4)
- Cannot read property 'string' of undefined | React.PropTypes | LayoutPropTypes.js
- React Tutorial: TypeError: Cannot read property 'props' of undefined
- Node error Cannot read property 'resolve' of undefined
- TypeError: Cannot read property 'equal' of undefined
- TypeError: Cannot read property 'javascript' of undefined + terser webpack plugin + react js
- react-router v5.1.0 Cannot read property 'location' of undefined ,
- Tailwind V3 causing TypeError: Cannot read property '500' of undefined
- React Material-UI Modal TypeError: Cannot read property 'hasOwnProperty' of undefined
- Axios ReactJS - Cannot read property 'setState' of undefined
- Uncaught TypeError: Cannot read property 'call' of undefined at __webpack_require__
More Query from same tag
- React router protected route with firebase auth check
- decodeURIComponent is not a function
- Cannot set React state to array of objects
- console.log(this.props) undefined
- ReactJS - passing parameters to functions
- React not rerendering props when render function is provided
- How to merge and unzip (.zip, .z01, .z02) in javascript (client side only)?
- Render unstanitized HTML with ClojureScript+Sablono
- React NavBar Component Prevent render
- How to list members from an GraphQL's Enum type with ReactJS
- React throws error - TypeError: Cannot read properties of undefined (reading 'greet')
- dispatch action and redirect by calling function without page reload in react redux ( Page Reload Problem )
- React-admin CheckboxGroupInput check some checkboxes by default
- Can't access state from parent component method
- React: App requests same endpoint multiple times
- React - setState in componentWillReceiveProps
- How to redirect to another view in React
- React call setTimeout at onClick seems not to wait
- What's the best way to detect in which div am i to change the style of a navbar in React?
- React class methods overriding
- How can we pass a color as a prop?
- How can create uniqe value in map function? Its need for key value
- React: Error referencing a function within state
- I cannot understand what the error is and why e.currentTarget.value is null
- Should I organize my react redux reducer composition based on the calls made OR based on the state a reducer manages?
- Can't access context.router with react-router-redux
- How to use "<Redirect>" inside a function?
- TypeError: Cannot read properties of undefined (reading 'string') with react joi-browser package
- Error: Actions must be plain objects. But i'm not using async calls
- Interpolating string for use in import. Unexpected token error