renatorib / react-sizes

:left_right_arrow: Hoc to easily map window sizes to props.
722 stars 36 forks source link

Fix resize throttle config. Wrong accessing of the configuration #28

Closed ghost closed 6 years ago

ghost commented 6 years ago

Currently it is not possible due to a bug to configure the throttle which is uses to delay the rerender of react when the browser window size changes. The default value is 200ms.

It is supposed to be possible to configure the throttle by using the SizesProvider provider component. This provider however stores the config under this.context['_ReactSizesConfig_'].throttle and not directly under this.context.throttle. This merge request fixes this.

Tested by setting up a react app which uses the SizesProvider to configure the throttle. The app simple prints the current width/height into a div

<SizesProvider config={{throttle:1}}>
        <TestComponent/>
</SizesProvider>

See issue https://github.com/renatorib/react-sizes/issues/27 for more details about the bug

renatorib commented 6 years ago

Ops 😅

renatorib commented 6 years ago

Nice 👍 thanks! I'll publish a patch version in a while

renatorib commented 6 years ago

@saschal-j5int react-sizes 1.0.4 published 🎉

ghost commented 6 years ago

Awesome. Thanks for the quick publishing. Will upgrade to the version