Add this suggestion to a batch that can be applied as a single commit.
This suggestion is invalid because no changes were made to the code.
Suggestions cannot be applied while the pull request is closed.
Suggestions cannot be applied while viewing a subset of changes.
Only one suggestion per line can be applied in a batch.
Add this suggestion to a batch that can be applied as a single commit.
Applying suggestions on deleted lines is not supported.
You must change the existing code in this line in order to create a valid suggestion.
Outdated suggestions cannot be applied.
This suggestion has been applied or marked resolved.
Suggestions cannot be applied from pending reviews.
Suggestions cannot be applied on multi-line comments.
Suggestions cannot be applied while the pull request is queued to merge.
Suggestion cannot be applied right now. Please check back later.
Overview
Fixes issue described in #262.
useNetInfo
is broken on multiple calls (which happens when components re-render).The
configuration
is defaulted to{}
andconfigure
is always called. The call toconfigure
then creates a newState
instance. TheaddEventListener
is only called on the first time and the listener is not re-added on subsequent calls.Overall I don't see how passing a
configuration
param is doable here as any attempt to add an event listener results in a re-render. I have changed it to not have a default value so it can work as it did before. If you do pass in a configuration param then you'll need to add a listener separately, I guess?Test Plan
I couldn't run the test suite as I got the following error