streetscape.gl icon indicating copy to clipboard operation
streetscape.gl copied to clipboard

Add react hook alternative to connectToLog

Open asmockler opened this issue 4 years ago • 0 comments
trafficstars

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: https://github.com/asmockler/streetscape.gl/commit/f9dabf306be87d267bb2429c060856829a159efb. 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!

asmockler avatar Jun 09 '21 04:06 asmockler