score:1
Accepted answer
you can create a new <route/>
on the /app
. you can pass the props down to map
as needed.
<route
path='/map'
render={(props) =>
<map
{...props}
coords={this.state.coords}
/>
}
/>
since you are on the home
component, you probably need to pass a function from app
down to home
via prop so you can update the, for example, coords state on the app
which you will be passing as prop down to map
. example code on app:
updatecoords = (val) => {
this.setstate({
coords: val
})
}
<route
path='/home'
render={(props) =>
<home
{...props}
updatecoords={this.updatecoords}
/>
}
/>
then on home
simply call this.props.updatecoords(somevalue)
to update the state of the coords state on your app
.
if you need to redirect right away i suggest using the <link>
(https://reactrouter.com/web/api/link) or use history api on app
this.props.history.push(`/${someroute}`);
Source: stackoverflow.com
Related Query
- Correct way to use button navigation in react
- what is the best way to use react router V6 navigation with redux and redux thunk actions?
- Correct way to use scripts in react with .core
- Is there a way I can use button in react to delete a item in an array that is stored in the state
- What is the correct way to use react hook useState update function?
- Infinite loop in React GET API call and correct way to use Hooks and useState()
- Correct way to use state in React
- Correct way to use socket.on in react
- Correct way to handle conditional styling in React
- Correct way to share functions between components in React
- Disable back button in react navigation
- Correct use of arrow functions in React
- What is the correct way of adding a dependency to react in your package.json for a react component
- Correct way to define an empty dom element in React
- Is it possible to use material-ui button navigation with react-router?
- Facing issue while adding radio button in react - input is a void element tag and must neither have `children` nor use `dangerouslySetInnerHTML`
- Browser navigation broken by use of React Error Boundaries
- React i18next and correct way of changing language
- React Navigation weird back button behavior in nested navigators
- What is the proper way to use React Memo with Flow?
- Is there a way to use React Components within Elm?
- Correct way to throttle HTTP calls based on state in redux and react
- What's the easiest way to use Create React App with Relay?
- What is the correct way to animate/transition between routes in react router
- Use Facebook Login Button with React
- React Redux correct way to handle error / success messages unique to each component
- Way to call hooks from button events in react
- What is the correct way to use inline style in react?
- Correct way to define handlers in functional React components?
- react way of setting focus on a particular button in functional component?
More Query from same tag
- How can I get my add function to only change contents of the selected index when editing state is true?
- User Login(pin) -> error(pin):"Request failed with status code 404"
- ReactJS react-app-rewired / config-overrides for raw-loader not working
- How to rewrite code in order for the code to be dry in react
- Why is dispatch function relocating to home page before rendering logout function?
- reactjs setState before render on update
- How to convert object keys to nested objects
- How to display a parent container on the main Router
- Typescript for mounted enzyme wrapper
- How do i change a property in state whose name is the value of a variable?
- React Hooks useState showing errors
- Right way to update state in redux reducers
- Using an if statement to apply inline style (React)
- react router and passport.js
- Returning webpage layout based on if statement
- React: How to add unique className?
- how to use template literal strings for modular css with JSX?
- Running two countdown timers sequentially in React. The second one is skipped
- How to dynamically request a React Component based on a variable value?
- React UseState hook for updating data - CRUD
- How to setState of a specific slider?
- How to test Material UI Select Component with React Testing Library
- Bootstrap doesn't work properly in ReactJS application
- How do I implement a Sequalize API into my React application?
- Next.js cannot find module loader.js
- Calling function in component class from Highcharts component in React
- How to use React BluePrint components with TypeScript?
- How to push inside nested array of object that have a precise value of a key in MongoDB?
- to extend an object returned from an async function
- Stop event listening after route change