yaodingyd / react-flickity-component

A React.js component for using @desandro's Flickity
314 stars 51 forks source link

fix #86: use getDerivedStateFromProps to set flickityReady state #91

Closed yaodingyd closed 4 years ago

yaodingyd commented 4 years ago

The warning message is because we do another setState in renderPortal method. This state change is necessary, explained in #80, but to fix this we move setting state into getDerivedStateFromProps which is the perfect usage case.

In order to use this lifecycle we also need to bump the peer dependency to 16.3.0 which introduced this method. Also move flickity to peer dependency as it makes more sense to let user manage the version of flickity.

yaodingyd commented 4 years ago

I have a demobox: https://codesandbox.io/s/react-flickity-w85iq

notice this must work with dynamically adding slides

yaodingyd commented 4 years ago

also remove lockfile because of https://snyk.io/blog/why-npm-lockfiles-can-be-a-security-blindspot-for-injecting-malicious-modules/ and https://github.com/sindresorhus/ama/issues/479#issuecomment-310661514

the fact that the version on lockfile is still 3.3.2 and no one noticed kind of proves the point.

theolampert commented 4 years ago

@yaodingyd LGTM