score:0
var newsearchparams = updatequerystringparameter(props.history.location.search, "timestart", startdate);
props.history.push(newsearchparams);
and then update your state with setstate.
if your component rendering first time , pass default value to state from queryparam.
function updatequerystringparameter(uri, key, value) {
let re = new regexp("([?&])" + key + "=.*?(&|$)", "i");
let separator = uri.indexof('?') !== -1 ? "&" : "?";
if (uri.match(re))
return uri.replace(re, '$1' + key + "=" + value + '$2');
else
return uri + separator + key + "=" + value;
}
Source: stackoverflow.com
Related Query
- Query string update breaks setState
- Query state in React, and setState or update if exists
- React update setState convert String to Array
- update setState with string of the key
- How to dynamically update query parameters to URL string in react and axios
- NextJS: Push new query string value to an existing asPath or update the existing query string
- react checkbox to pass a string value to update query
- How do you programmatically update query params in react-router?
- setState doesn't update the state immediately
- How to parse query string in react-router v4
- How to query by text string which contains html tags using React Testing Library?
- GET with query string with Fetch in React Native
- How to get query string using React?
- How do I update the state (using ReactJS) if I should not call setState in componentWillUpdate?
- How to update the Redux store after Apollo GraphQL query returns
- React Hooks - How to get parameter value from query string
- React setState can only update a mounted or mounting component
- Random query string appears in react-router
- How to parse a query string in React Router
- UI doesn't update until tap on the screen when setState is called inside a realm listener callback
- React-router: changing query string does not re-mount the component
- React Apollo GraphQL : Expecting a parsed GraphQL document. Perhaps you need to wrap the query string in a "gql" tag?
- React Apollo: Dynamically update GraphQL query from Component state
- How to update query param in url in React?
- React Router: Update only one query parameter instead of replacing all
- How to generate query string from a nested object
- Maximum update depth exceeded. This can happen when a component repeatedly calls setState inside componentWillUpdate or componentDidUpdate
- How can I create api end point in Next.js with query string
- How to get URL query string on Next.js static site generation?
- How to update state with setState before render
More Query from same tag
- I want to display my labels "etc vegan, pasta...so on", by using map from firestore?
- Method in React component not rendering HTML
- React how can I build minify code in react library
- What is going wrong on this line of code? (React, Game Of Life)
- How to pass onClick function in sibling components using functional components?
- How to test props after being assigned to new variable
- React, pulling state out of components
- Best approach to display updated list in React via fetch again or through some other way
- is there anyway to make js executes this script line by line
- React upgrade issue "Error: Path is not a string"
- how can I pass a target url address to a form in react.js?
- Loop buttons in react.js
- How can I send messages to my queue and a post request?
- Set tabs to active using React
- Updating state before render: propType marked as required but undefined
- Lift state up between components in react
- The context `router` is marked as required in `Link`, but its value is `undefined`
- How to filter the retrieved items using a pnp.sp.web REST call to a SharePoint list
- Dynamically Rendering a React component
- Typescript and Context API
- How to override a parent class method in React?
- Make webpack ignore a certain import
- React useEffect caused infinite loop
- Material UI - remove border from one of the textfields
- Unhandled Rejection (TypeError): observer.complete.bind is not a function
- How can I remove an attribute from a React component's state object
- React Routing not working, upgrading from v5 to v6
- React: component's render() is NOT invoked after this.setState() is called
- TypeError: Cannot read property 'value' of undefined on components (ReactJS forms)
- React useState vs raw variable