Search
 
SCRIPT & CODE EXAMPLE
 
CODE EXAMPLE FOR JAVASCRIPT

changing parent function states in child function

function Parent() {
    const [value, setValue] = React.useState("");

    function handleChange(newValue) {
      setValue(newValue);
    }

    // We pass a callback to Child
    return <Child value={value} onChange={handleChange} />;
}
Source by webomnizz.com #
 
PREVIOUS NEXT
Tagged: #changing #parent #function #states #child #function
ADD COMMENT
Topic
Name
3+6 =