score:0
Accepted answer
pass it something like this. use state prop and pass necessary items. in the below example visibleflag which is a boolean is passed along the link.
<link to={{
pathname: '/client',
state: {
visibleflag: true
}
}}>
<button
onchange={(event) =>{
event.preventdefault();
this.setstate({
bvalue:"unavailable",
disable:true
})
disabled={this.state.disable}
>book now</button>
</link>
accessing:
const { visibleflag } = this.props.location.state
using withrouter hoc to access the router props
import { withrouter } from 'react-router-dom'
....
//code
....
export default withrouter(yourcomponent)
score:0
you can pass state/props to other components using link
<link to={{
pathname: '/client',
state: {
flag: true
}
}}>client</link>
and in target component that will render
const { flag } = this.props.location.state;
if functional component
const { flag } = props.location.state
Source: stackoverflow.com
Related Query
- How can I pass props from one component to another using Link and router in react
- How to pass a prop from one component to another when using react router link
- I can not get the state from react router Link component using useLocation. So how can I pass it?
- How to pass props from one component to another using optional handling in react hooks
- How can I pass values from a functional component through a React Router Link to another functional component?
- React-Router: pass props from one component to another using link
- Error Coming when passing props from one component to another and vice - versa in react using typescript
- How to navigate from one component to another by clicking a button using React router
- How can I pass the state from one component to another and how can I modify the state?
- How to pass data from one component to another component in onchange using React js
- How to pass a json array that comes from backend to child component using props and react hooks?
- How to transfer data from one parent component to another parent component in react using router / router params
- React - How can I pass API data from one component to another in a different js file?
- How can I match data from an object and pass it as props to another component that displays dynamically?
- How to pass props onClick from one component to another in React JS
- React couldn't pass a data from one class component into another using Link
- How can I pass props from one component to another withour Redux
- How can i pass data from one component to another using hooks
- How to extract props and states from one sibling component to another with react hooks?
- How to set state in parent from one child component and access the state in another child component using react and typescript?
- How to pass value from one component to another using onClick in React
- how to pass props from one component to other in react router that don't have parent child relationship?
- How to pass props from one component to another along with props validation - React Hooks
- How to pass json data from one component to another using functions in react
- how to pass the data from one page to another in react.js and using reach router
- How to pass the match when using render in Route component from react router (v4)
- Can we pass setState as props from one component to other and change parent state from child component in React?
- How to pass data from one component to another in React or React-Redux?
- How to pass data from a page to another page using react router
- How to pass data from one component to another while using API in reactjs
More Query from same tag
- How to make one dropdown menu dependent on another
- What does react test-utils expect when it refers to ReactComponent tree?
- Server Error TypeError: Cannot read properties of undefined (reading 'apps')
- Function called on componentDidMount instead onClick
- How to manipulate style/atributes in React DOM
- SetState Is Not A Function on OnChange
- React (Next.JS) Import Component After Page Loaded
- State does not get updated immediately in react js
- Showing JSON results on front-end when using fetch
- How to detect Iframe video has ended in reactjs
- ReactJs, Data only loads when I clicked on the accordion header
- ReactJS - Same method, different results
- React-Bootstrap Grid layout not applying
- ReactJS Read URL parameters
- Combining multiple const = in an array?
- IntelliJ TypeScript plugin complains that "window is not defined" in React project
- concise and readable syntax for props in a react component in typescript
- Inject children into react component passed by props in TypeScript
- How to set the value of inputs with ReactJS hooks?
- ReactJS: TypeError: this.state.myText.map is not a function
- library not recognised in reactjs
- Generate Route dynamically - React
- how to pass array values to Formik select
- React-Router open Link in new tab
- How to get the time of the time slot with react-big-calendar?
- Rendering inline styles based on prop in Rect
- Fetch throwing error with 302 in componentdidmount react
- Re-render child when prop changes in App.js
- Get TypeError: Cannot read properties of undefined (reading 'forEach') when pass a params
- Search in custom table - React