Functional Vs Class-based components in react #react #statemanagement #reactjs

preview_player
Показать описание
useState and useEffect are two of the most commonly used hooks in React.
useState allows you to add state to a functional component. It takes an initial value as an argument and returns an array with two elements: the current state value and a function to update that value. You can call this function to update the state value, and React will automatically re-render the component with the new value.
In this example, we're using useState to add a count state variable to our component. We're initializing it to 0, and we're also creating a function setCount that we can use to update the count variable when the button is clicked.
useEffect allows you to perform side effects in a functional component. It takes a function as its argument, which will be executed after every render of the component. This function can perform any side effects you need, such as fetching data from an API or updating the document title.
Join this channel to get access to perks:
Рекомендации по теме