score:1
to fix this issue, withrouter
can be used like this in searchresularpage page :
import react, { component } from 'react';
import { withrouter } from 'react-router-dom'
class searchresultpage extends react.component {
constructor(props) {
super(props);
this.state = {
searchvalue :'',
paramvalue : ''
};
}
componentdidmount(){
this.setstate({
searchvalue: this.props.searchtext,
paramvalue: this.props.location.state
})
}
render() {
return (
<div>
{this.state.searchvalue}
{this.state.paramvalue ? this.state.paramvalue.hello : ''}
</div>
);
}
}
export default withrouter(searchresultpage);
hope it helps :)
Source: stackoverflow.com
Related Query
- Unable to pass state value through react jsx. Getting error - Unexpected token : 'this'
- Unable to send the updated value of state through props in react js
- Unable to pass state value through react_router4
- pass a childs state through react context api to parent component
- How do I pass a React Context's state through an onClick function created in a method inside that context class?
- Set value of prop in child component and pass value back to state of app.js, react
- How to pass one state value to another state on initialization in react js
- How to pass state value to a callback function using React Hooks
- Passing a state or prop to pass a value to child component in react
- Unable to set the value of a variable to state variable in react js
- React state value became null when it pass to model
- On React hook component unmount, unable to get updated state variable value
- Setting state in React Enzyme unit test which I pass through props
- Through a function passed in context, React state always has the initial value
- Unable to update the state value in React Js forms
- pass the value of a checkbox to a state in React Js
- not able to pass value through link and router react js
- Pass Redux selector value to react state without rerendering in useEffect
- pass boolean state value from parent class to child class when a button is clicked in the parent class in react js so that i can load quizes with bool
- how to go through react state variable array and determine if it has one true value
- React functional component test file unable to update state value and call its props function
- React and useReducer unable to access the state value
- React can't pass state value to state array
- React Hooks - Unable to get updated state value
- How to pass value of state in a function in react using hooks
- onChange is not working in react functional component while changing the value through state update
- Unable to pass down state using react context
- Unable to render a state variable value in React Js
- Unable to reset value in State of React
- React Images Won't Load when I pass my src value through array
More Query from same tag
- How to use Flow with React.createRef()?
- MUI Rating component is rendering revert
- React State Management: Context API as global store
- Set style property of elements in a map loop in JSX in React
- splitting an array with one item into an array with many items
- useEffect doesn't run after rendering
- Force remounting component when React router params changing?
- React and importing classes
- React-native android WebView handle clicked Url before loading
- How do i setState with hooks of an object which has multiple arrays ? How to setdebtors here?
- How to change Font Awesome props with respect to media queries in React.js?
- Does React not explicitly export forwardRef?
- babel-plugin-react-css-modules is not matching styles with styleName
- Using hooks to manage display/hide of a menu
- ReactJs Checkbox - cannot uncheck
- Dynamically change image source based on boolean value
- Accessing array inside of Object
- How to chain multiple dispatch actions one after the other in redux?
- What type to specify for event handlers tied to multiple fields?
- React combo doesnt select proper value
- I can't Upload Images from React to Django backend
- componentDidMount not getting props value
- setState is not updating DOM
- How to control a boolean in redux?
- Passing props to functional React component in Typescript
- React component to hooks, how to migrate redux actions triggered by redux-thunk?
- Invariant Violation: findComponentRoot when using Link & Tables
- 'Cannot find module' when using webpack loaders
- import assets issue, electron forge
- ERROR in ./src/redux/store.js 5:26-34 export 'reducers' (imported as 'reducers') was not found in './reducers/index' (possible exports: default)