For function components, the useState
hook is how you make your component stateful. This replaces the previous convention from class components where values were stored in a this.state
object and manipulated using this.setState()
.
The hook returns an array with two values: the state value your are storing and a function that allows you to updated it. When instantiating the hook, the initial state value is determined by whatever value you pass it.
const [value, setValue] = useState(null)
I'm a little confused about the remove prop. I was under the impression that we shouldn't call hooks inside if statements.
I'm a little confused about the remove prop. I was under the impression that we shouldn't call hooks inside if statements.
Hey Diana, according to the Rules of Hooks If we want to run an effect conditionally, we can put that condition inside our Hook