purescript-react/purescript-react-basic-hooks

[question] console.log in the render method

mananamenos opened this issue · 1 comments

In js world I sometimes find useful putting console.log() inside render method to track when the component rerenders. Is there any function already or I'd need to write some monad transformer? Here is the snippet im trying
https://github.com/spicydonuts/purescript-react-basic-hooks/blob/b2b75a778893b7d0f43daade145d53b6205bd4c1/examples/counter/src/Counter.purs#L12

I usually use spy from the purescript-debug library to inspect things while developing. You could also build a safe logging hook using useEffect.

If those aren’t sufficient, the unsafeHook function can promote any effect to a hook. You just need to be careful with the type you assign it.

And finally you can perform any effect during render using unsafeRenderEffect. That’s only slightly better than unsafePerformEffect though.