score:0

Accepted answer
//parent 'App' component

function App(){
  const [success, setSuccess] = useState(false);

  return(
    <>
       <TextInput success={success} setSuccess={setSuccess}></TextInput>
    </>
  )
}

function TextInput(props){
   const {success, setSuccess} = props;
   
   // In here you can refer success and setSuccess normally as you would even if this is in a separate file
}

score:0

function TextInput({success, setSuccess}) {
  // use success/setSuccess from props
}

score:0

function TextInput(props) {
//Access it using props.success
}

score:0

function App() {
  const [success, setSuccess] = useState(false);

  return (
    <TextInput success={success}  />
    <FormComponent success={success} /> 
  );
}

Related Query

More Query from same tag