score:0
it seems like you are appending data to your array instead of replacing it with new values. you should initialize a new array if you don't want to retain previous results.
const info = {country : country};//country array
const data = [];
data.push(info);
this.setstate({
data:data
});
Source: stackoverflow.com
Related Query
- State in Reactjs holding the previous state value, how to update the state with new edited form value
- In Reactjs how do I update the correct value in the parent state with a callback that's been passed to a nested child component?
- How do I call setState with the previous state plus an additional value in a redux connected controlled component?
- React. How to update the state with previous state?
- How to change the value with all specific key in the nested state in ReactJS
- How can i update context value with the state value
- How to update the current state with current and previous state with react hooks
- how to update the state if dropdown has selected value with Hooks and useState
- How to get previous state value in reactjs
- How to dynamically update the value for any input field with one event handler function, using hooks
- How to set defaultValue, value={this.props.value}, and update the value of a text input with React?
- Why does calling useState's setter with the same value subsequently trigger a component update even if the old state equals the new state?
- How to update state of a component with value from reducer state in react-redux?
- How to set the value of inputs with ReactJS hooks?
- How to update state with the useState hook
- How to update the correct state value in a parent component that gets its value from a child component using hooks in react?
- Update an specific value inside the state with the reducer
- How do I use the spread operator to update a state value in React?
- ReactJS best way to update the state with asynchronous setState
- How to update specific value when the state is an array of objects - React
- How to assign a value to state and use setState in ReactJs with Typescript
- How to update the state with the latest fetched item with an interval callback function inside useEffect?
- How to get or update the value in variables in reactjs like angular?
- React: how to avoid re-rendering a component with a hook that returns always the same value but changes its inner state
- How to change the state of a specific value in an array with condition
- how do i update state in react for updating the value of an object inside an array using array.map function
- Reactjs: How to update value in state array with react hooks?
- When selecting an option in a dropdown, how do I change the state with onChange but with a value other than the one inside the option tags
- How do I update Reactjs State with data I retrieved using a fetch API call?
- How to update the state of with multiple elements by their key in React?
More Query from same tag
- how to parse json after exception handling promise with isomorphic-fetch
- Cant get a text box state to refresh with user input, keeps going to default state despite using setState
- React js common layout with React Router
- How to make useSelector() work (basic setup)?
- function argument types when get a value from an HTML element on react
- React update state with nested object
- How to only allow a specific element type as children using Flow and React?
- Cannot read property 'length' of null in React component
- Map objects with matching owner
- How to make react-google chart dual-y-axis
- Cannot upgrade Material-Ui Version from 0.14.4 to 0.15
- React useState hooks initial value is null, after few seconds when got value then not updating where is use the value
- How to write Mozilla specific CSS using withStyles
- Connect after routed component causing boolean values in props
- React use one event handler for different inputs
- React Material Ui Autofill Text input
- truncate text in reactJS
- How to add aria-required to Material-UI select component
- How can I use this toFixed(2) in these codes?
- How can I align my chat entries to the right in the chat room?
- How to separate routes from index.js in React
- React-native/Enzyme : mount throws "unknown props" on native elements
- Can i put a setTimeout() in a dynamic class?
- Error: findComponentRoot when using divs
- StyledComponents with Typescript and ThemeProvider. What are the right types?
- How to make a "mouseleave" analogue for a "touch" event?
- Why is the span element rendered by the Text component from the Grommet library, able to get margin-top?
- How to deal with issue when user doesn't exist
- Binding methods in react components
- NextJS- Update URL on SSR fetch request is done