Answers for "react Explain how to update a component's state from a child component."

1

how to define state in react function

import React, { useState } from 'react';

function Example() {
  // Declare a new state variable, which we'll call "count" 
  const [count, setCount] = useState(0);
  return (
    <div>
      <p>You clicked {count} times</p>
      <button onClick={() => setCount(count + 1)}>
        Click me
      </button>
    </div>
  );
}
Posted by: Guest on September-21-2020
2

component did mmount

componentDidUpdate(prevProps, prevState, snapshot)
Posted by: Guest on May-01-2020

Code answers related to "react Explain how to update a component's state from a child component."

Browse Popular Code Answers by Language