score:0
Accepted answer
Finally got the answer!
updateList(dataa){
this.setState(ps=>(
{ listState: [
dataa,
...ps.listState
]}
)
)
}
"updateList" in "App.js", this works
score:0
You need to pass object with key "title" and "details". Not input1
and input2
. So just update like this in Form:
const newItem = {
title: this.state.input1,
details: this.state.input2,
}
this.props.onsubmit(newItem);
Source: stackoverflow.com
Related Query
- react (class based) : How can I update JSON object in parent component using setState after the object being passed in function from child to parent?
- Using React hooks, how can I update an object that is being passed to a child via props?
- How can my child component update my parent component in React JS?
- How to update the state of nested json object in react using hooks
- Using React Hooks useReducer, how can I update an object by ID efficiently?
- How can I update component in React after adding a new item into the database, using react hooks?
- How can I convert a class with a constructor to a functional component using React Hooks?
- How can I add or remove class using querySelectorAll() in react functional component
- How can I test if child React component was rendered based on a URL change using Jest and Enzyme
- I'm using react-slick, how can I export a React Component as a single element but remove the parent div on render
- How to override child css class in parent react component using sass
- How can I set up state in a React app using arrays in a json object as well as arrays not in the json object?
- How can I communicate between two react sibling component directly without using parent component?
- How can I Send data to another Component without using Parent and Child Relation in React
- How can I update my child component state from the parent class in React?
- How can I convert the this cascading dropdown class component to functional one using React Hooks?
- How can I update State in React using the React-Select Component and User Selection?
- React - How can I render a component within a class by using OnClick?
- How can I set React component state based on previous state using Immer?
- How to update status of Parent sate using functional component react
- How to send array of objects data from child component to parent component and store in the parent object using react hooks?
- How to declare defaultProps on a React component class using TypeScript?
- using css modules in react how can I pass a className as a prop to a component
- How to get a React Component reference to change its class using classList?
- How to notify parent component of property change when using react hooks?
- How to update props of React Component rendered using ReactDOM.render()
- How can I spread props to a React component that uses exact props when using Flow?
- How can I test css properties for a React component using react-testing-library?
- How do I manage state on a React component that can have state changed from the parent or from events upon it?
- How can I render a component X amount of times based on a javascript object in React?
More Query from same tag
- how to memoize http request page number in react/redux
- Unable to understand double arrow function which returns another function
- React & Redux: State of component is not updating even with mapStateToProps
- React HOC with multiple components
- React component not making ajax call
- make disabled button trigger onClick event in react
- How can I set react Hooks to another value when it is already set
- Too many re-renders. React Limits the number of renders to prevent an infinite loop - React hooks
- Add Property to StatelessComponent
- How Mapping Routes in React Router with Protected Function?
- Convert componentWillReceiveProps to getDerivedPropsFromState
- Background image Sass, Css and Express
- how to change my button color based on some condition? I want less in one color and more in another color
- How to use multiple nested dynamic routes with getStaticPaths?
- get value from other react component
- POST to API from React frontend is not working -- Error 400
- How do I reduce the number of images that appear on my carousel?
- Children stored in an array in Parent's state don't receive new props
- TypeScript React <img /> onLoad event.target can't find naturalWidth naturalHeight
- How to emulate window.location with React Router 5?
- how to control child elements by onClick from parent in reactjs?
- How to prevent infinite loop in my React code when using setState inside useEffect
- How to get latest component variable value in 'useEffect' hook?
- React redux async mapStateToProps
- Getting "TypeError: Cannot read property 'classList' of null" on my React project with useEffect when trying to access a script?
- Await value before useEffect runs
- Sort Array with two object inside
- Theme not Changing in `AppBar of material-UI?
- Serve static folder with Spring Boot and React Router
- Show a pop-up window with information coming from an element and its totals, from one of the table in react.js