Add react hook alternative to connectToLog
asmockler opened this issue · comments
Hi! I've started using streetscape.gl
and noticed that there are several react warnings logged about componentWillReceiveProps
and thought I would see what I could do about fixing them. Additionally, the ergonomics of connectToLog
could be better for functional components. I propose adding some hooks as an alternative to connectToLog
.
I've tried out two implementations in my project: useLogConnection
and useCurrentLogFrame
. The first returns the log
, much like connectToLog
. The second attempts to call log.getCurrentFrame()
and return the current frame.
I've put up an example of how useCurrentLogFrame
would work here: asmockler@f9dabf3. I can also push an example of useLogConnection
, although it is pretty similar apart from the last line.
I would love to hear your thoughts!