renatorib / react-sizes

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

Dispatch sizes again when the props are updated #30

Closed ncuillery closed 6 years ago

ncuillery commented 6 years ago

The "Mess with props" example in the README.md file doesn't work if the component property (mobileBreakpoint in that example) is dynamic.

Let's imagine you have a slider to adjust the value of that props. If you interact with the slider once the component is mounted (componentDidMount has been called), the mapSizesToProps is not called until the window is resized.

This PR simply adds a componentDidUpdate method which triggers this.dispatchSizes().

renatorib commented 6 years ago

Thanks @ncuillery! I'll publish a patch version soon.