Answers for "communication child to parent react js"

1

communication child to parent react js

import React from 'react';

import Child from './Child'

export default class Parent extends React.Component {

      constructor(props){

            super(props);

            this.state ={ text:''};

       }

     handleChangeInParent = (event) => {

             this.setState({text:event.target.value})

     }

    render() {

        return (

                  <>

                     <p>You have written: </p>

                     <p>{this.state.text}</p>

                     <Child handleChange={this.handleChangeInParent}/>

                   </>

                )

      }

}
Posted by: Guest on November-24-2020

Code answers related to "communication child to parent react js"

Code answers related to "Javascript"

Browse Popular Code Answers by Language