score:2
it can be done when you replace state with data.
<link
to={{
pathname: '/popular',
data:{
testfavorite: this.testfavorite
}
}}>
also replace here
this.props.location.state.testfavorite();
meanwhile, if you also want to pass data as props you can use state along with data
Source: stackoverflow.com
Related Query
- How can I pass function through Link in React?
- How can I pass values from a functional component through a React Router Link to another functional component?
- How can ı pass function with state for react useContext
- React Native - how can I pass a function to a stack screen in a navigator?
- How do I pass a React Context's state through an onClick function created in a method inside that context class?
- I can not get the state from react router Link component using useLocation. So how can I pass it?
- How a React function output can be added in a embed-HTML link
- how to pass the current item to the function so that i can remove it from array in react component?
- How Do I Pass a Function Through A React Component For Data Sharing Between Parent and Child?
- how can I pass a single argument to a react function that returns a component?
- how to pass a function through multiple nested loops in react
- How can I pass a function as a prop to a React component using react-router <Redirect />?
- How can I pass down through props a string of text with a link embedded within?
- How can I pass function using props in React Router Link?
- How can I pass the children of a function component to another function component in a react class?
- how to capture the file of an input element so that I can pass it as an argument to another function in react
- How to pass a function through props in React to a function in a different component?
- How can I pass props from one component to another using Link and router in react
- How can I pass arguments to a bound function to a React child?
- How can I pass multiple parameters through a React <select> component?
- How can I pass a function when linking with React Router?
- How can I pass my theme classes in my react function to stylize?
- Using a Custom React based Modal, how can I pass a dynamic triggering function so I can re-use the component?
- how do I pass additional props into a react component through a higher order function
- How can I scan through the list of string array items to identify which part matches regex expression for url and convert it to link w react typescri
- how to test props which is pass through Link in react router with React-testing-library or jest
- React you cannot pass props inside a regular function but you can pass a prop through a class component
- How to pass function as prop in react routerv5 with the Link tag
- How can i pass HTML inside React Hook Function and display inside my component secure?
- How can I pass in the arguments to a function in react from within the html?
More Query from same tag
- extending default theme chakra ui
- How to use whitelist in redux-persist v5?
- How to make API call on slider stops moving?
- what is xargs rm -f in node pre install
- Losing JWT token after browser refresh
- Add an array of Objects to a mutation in apollo-react
- `this.props` inside `getDefaultProps()` of React?
- How to delete data from DB using React, and hitting a rest API that i created using php and mysql?
- React Best Practice: logic vs functions in JSX
- Filter array and show results in React
- Hardcoded expected string vs extracted variable in React shallow test
- Trying to import a JSON file into React but not working
- ESLint: Only declares and type imports are allowed inside declare module
- MobX + React - Getting observable to re-render within an external component
- react component disappears on heroku after a second
- How can I get input radio elements to horizontally align in react [material-ui]?
- How to enable polygon (geofence) editing enable,on clicking polygon itself, without clicking on Edit button
- React Link not working in an independant component
- React strange internal issue depending on variable name
- Strange behavior when parsing JSON cookie using cookie-react in React / NextJS
- Component not defined after importing
- Component doesn't Update on Props Change
- Reactjs Redirect Url Changes but component not loading
- Navigation Drawer for Web Application
- ReactJS and CSS rendering
- What is the 'React' way to scroll to a certain Component on the page?
- link changes but page does not
- Adding a react component to a vanilla JS file
- How to access the passed prop array inside the child component
- Why is the value of a React controlled input element not being updated properly from a Chrome extension?