February 2019
Beginner to intermediate
180 pages
4h 4m
English
To make writing cleanup code more convenient and easier to remember, ReasonReact provides self.onUnmount, which can be used directly within a component's didMount life cycle (or anywhere that has access to self). This allows you to write the cleanup code alongside its complement instead of separately, within willUnmount:
didMount: self => { let intervalId = Js.Global.setInterval(() => Js.log("hello!"), 1000); self.onUnmount(() => Js.Global.clearInterval(intervalId));},
Read now
Unlock full access