score:0
Accepted answer
handlechange should be:
handlechange(selectedoption) {
this.setstate({criteria: selectedoption});
}
selectedoption type is:
{
value: string,
label: string
}
score:0
figured it out, thanks to armin yahya for pointing me towards the right direction, as i was not aware of the selectedoption type. here's what i ended up writing that has my handlechange function working properly and updating the url for the api call:
handlechange(selectedoption) {
if(selectedoption.value == 'name') {
this.setstate({criteria: 'patient?name='});
}
if(selectedoption.value == 'bday') {
this.setstate({criteria: 'patient?birthdate=eq'});
}
Source: stackoverflow.com
Related Query
- React-Select onChange to store a value to pass to API call
- Setting a default value on a react select dropdown that is populated from an API call
- Select in ReactJS is picking up previous value after API call at onChange function?
- React Select - How to show / iterate through data from api call in option instead of hardcoding options?
- How to pass an object value in a form's select field onChange (using React, without Redux)
- Fetching data from store if exists or call API otherwise in React
- react select onChange returning previous value instead of current
- pass id and value to set of select input in react js
- React select onChange not changing selected value
- React Component as Const select onChange passing selected value
- Render select option based on a API call in react
- select option from dropdown using API and get that selected value but i am getting last value which i have not selected in react
- How to pass variable as a parameter in api call fetch in javascript, react native
- React hooks, grab value of checkbox onChange and pass to submitForm
- How to Get value of select onChange in Functional Component in React
- How to set default value in material-UI select box in react (after API call)?
- Select value doesnt change the first time I trigger onChange event when using setSate React
- In React js How to Pass Input value to API Parameter in current component
- React Select pass multiple options in parameter on onChange
- How to api call in onChange function on CheckBox field React js
- Setting a default value for a select when select is based on API call
- Pass data in React FullCalendar with API call
- React select onChange doesnt use the options value
- Function call and pass value in the same OnClick - React
- REACT - How to pass a function to an axios api call
- How can i store api response in variable and pass it to react popup video player
- I do not know how to store json data from an api call within a nodejs express server, and send it to a react native client
- How to populate select options from an Api call in React js on page load
- Pass the key value pair to an API in React JS?
- React | How to interpolate value from an input into API call
More Query from same tag
- How to convert the DD-MM-YYYY HH:mm format to epoch time using moment or js?
- ESLintError in plugin 'gulp-eslint' - Parsing error: Unexpected token
- not re-rendering on setState
- Input not re-rendering onChange with hooks
- Trying to find some function like setFieldError on Antdesign Reactjs
- Invariant Violation: React.Children.only expected to receive a single React element child
- When the Next js app refreshing, useEffect not dispatching redux saga action and updating the state
- ReactJS: Calculating direction of 'joystick' while dragging (using Framer Motion) and updating div effects depending on position
- How granular should Relay/Apollo fragments be?
- TypeError: Cannot read property 'type' of undefined in react js
- How to use useFormik hook with async await in onSubmit event?
- How to use global var in react?
- How do i change a property in state whose name is the value of a variable?
- Maintain usestate for different onclick
- REACT PDF: Cannot use the packages to show static PDF file
- Reactjs remove specific index of array
- Update component by executing function in another
- Hooks are not rendering in React at all
- Why react-router Route attr render remount not rerender when component update?
- React: Fetching data from a nested array
- No need for state in React components if using Redux and React-Redux?
- How applying logical AND (&&) in firestore query
- How to create an icon dinamically by its name?
- Data table not displaying
- Get values from an array / object in React
- React setState with nested Json
- How to PATCH and DELETE on Firebase using Reactjs?
- How to determine which component is for a React child?
- Cycle Through List Items Mapped From a State (javascript)
- Importing css into react js