Loading tutorials
useState, that you have used useEffect with a cleanup function and a dependency array, and that you know how JavaScript closures capture variables. The previous chapter separated event handlers, which run because the user did 6 min readuseState, and basic useEffect usage with a cleanup function. The previous chapter covered which values count as reactive. This one explains what React does with those values once you list them in a dependency array5 min readuseEffect with a cleanup function, and that every reactive value an Effect reads belongs in its dependency array. Earlier chapters covered both. Here we look at a case where following that rule correctly still gives behavior you don't want. The Effect r6 min readuseState, and how useEffect works with a cleanup function and a dependency array. The previous chapter ended with a chat room that reconnected whenever the user changed the theme. H5 min readuseEffectEvent, which the previous chapter covered. Here the question is narrower: when an Effect Even6 min readuseEffectEvent and call it from an Effect. It also assumes you know that an Effect Event always reads the latest props and state. Earlier chapters covered both. Here we look at a design choice that comes up as soon as an Effect Even5 min readuseEffectEvent and call it from inside an Effect, and that you understand why it always reads the latest props and state. It also assumes you are comfortable with useEffect cleanup and the dependency array.6 min readuseEffect and its dependency array work, and how the react-hooks/exhaustive-deps lint rule reports missing dependencies. Earlier chapters showed that an Effect re-synchronizes whenever a reactive value it reads chang6 min readexhaustive-deps lint rule checks every Effect you write. This chapter shows how that rule, and its companion rules-of-hooks, handle functions created with useEffectEvent. You will learn which values the linter asks you to list and which it leaves out. You will also see the mistakes it catc6 min readuseEffectEvent and that an Effect Event reads the latest props and state, both covered in earlier chapters. It also assumes you are comfortable with setInterval, addEventListener, and async/await inside an Effect, including 6 min readuseEffectEvent, that Effect Events read the latest props and state, and the basic rules for calling them. Here we apply those ideas to a common situation: a custom Hook that takes a callback from its caller.5 min readuseEffectEvent works: how to declare an Effect Event, how it reads the latest props and state, and the rule that you call it only from inside Effects. Earlier chapters showed where it fits. This one covers the cases where it does not fit. In these cases an Effect 6 min readexhaustive-deps lint rule treats it. It covers one practical question: which React version you need, and what changes when you move from the experimental API to the stable one.6 min read