re: ReasonML with React Hooks Tutorial — Building a Pomodoro Timer VIEW POST

TOP OF THREAD FULL DISCUSSION
re: Great article! I just have a question regarding updating the document title, isn't that a side-effect? why not do it inside another useEffect hook...
 

Semantically speaking, yes that is a side effect. I feel like if I were calling React.useState(() => 0) instead in order to manage my "ticks" I would use useEffect and pass that ticks variable as a dependency.

When calling useReducer like this, you can imagine the Tick action as the dependency with the reducers switch expression as the effect execution.

Before the hooks version of ReasonReact, you would update a ReasonReact reducer by calling ReasonReact.UpdateWithSideEffects - meaning your effects were also performed in the reducer.

See this section for what that used to look like github.com/reasonml/reason-react/b....

Hope that makes sense!

code of conduct - report abuse