score:6
Accepted answer
you should use the state, because
you should use a state in the component which renders wizard
, and when step1
is finished, it alters that state, which then will be used in step2
.
this is called lifting state up.
score:2
props
, like state
, is read-only and should never be mutated.
you should use a callback:
<step1
datawizzard={this.state.datawizzard}
updatedata={idcreation =>
this.setstate(prevstate => ({
datawizzard: {
...prevstate.datawizzard,
idcreation,
},
}))
}
/>
then you call the callback in step1
:
updatedata() {
this.props.updatedata(432876);
}
Source: stackoverflow.com
Related Query
- Directly modify parent props from the child in react
- update react child component's state using props received from an async api call made in the parent component
- React Router: props aren't passed down when directly accessing the URL of child component. Will I need to use the same state in both parent and child?
- What causes the failure to pass props from parent to child in this React application?
- passing props from parent to child (while the child is the parent himself) react js
- How to use onClick event to pass the props from child component to parent component React Hooks
- Accessing React component children props from the parent
- In React, is it a good practice to pass all the props from parent to child component?
- Passing event and props from child to parent in react
- React what's the right way to get a parent props from its children
- Passing Values via Props From React Stateless Child to Parent
- Updating Child Component Via Change of Props from Parent in React
- How is an argument for a callback in React being passed from the child component to the parent component?
- React child component not rendering props from parent value
- React TS - How to pass props from a parent component to a deeply nested child
- Using React Hooks, when I pass down a prop from parent to a child component, the prop in the child component is undefined
- How to pass input values from a child Form component to the state of its parent component for submission with react hooks?
- React router dom passing data from parent component to child router component does not pass the props.match
- How does the child component receive props from the parent component without listening for the lifecycle method?
- Props are not passing from parent to child components in React Functional component
- React collect child component data on some event from the parent component
- Passing a prop from a Parent component becomes null in the Child component React
- React - Passing a value from child component to the parent component
- react pass props from child back to parent
- How to handle the props from Parent Component to child component to populate props data in the form for updation
- Update parent state based on props and onClick from child in React
- Is there a way to force a re-render of a child component from the parent component without using changing its props in React?
- Calling a function to change state in parent component from the child component in react
- How to get parent props from child composition component React
- React & TypeScript how pass data from child to parent at onClick via props
More Query from same tag
- How to find and update specific value in nested object array in typescript
- In a Redux reducer, if state is not defined, can you immediately return the initial state?
- How to customize Autocomplete tag - Material UI
- I am troubling integrating react-Dropzone-Uploader
- self.scope['user'] in Django channels keeps showing up as AnonymousUser
- Is there a way I could href to a local const file in a link tag
- Search is not working in mui-datatable, reactjs?
- React/Gatsby: Using CSS grid with alternating number of columns in each row
- React TypeError: "x" is not a function
- CKEditor5 image resize not working correctly
- React/JS if and for conditions
- Child route is blocking the parent route`s render
- React hook useEffect returns empty array at first
- I need to set checkbox checked when its value is true
- importing image dynamically (React Js) (Require img path cannot find module)
- prevent duplicate while merging redux array of objects with setState array
- React Router with Redux: Pass only necessary props down to child level routes
- Use static JSON file after build on create-react-app
- Error: App(...): Nothing was returned from render. This usually means a return statement is missing
- return new state, don't mutate it. Am i doing it right way?
- ReactJs: How to go back to a previous page NOT using Routes?
- How to load data from multiple json files in react
- ReactJS passing parameters from sibling to sibling components
- spring-boot:Object as API request getting null
- Resetting input field (controlled component) in a nested state in React
- How to redirect to login page on click of logout in react
- Iterate over array if the prop is there without getting 'cant iterate over undefined' error
- React Typescript and useCallback
- TypeError: Text.isText is not a function
- Condition based routing in react