yaodingyd / react-flickity-component

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

watchCSS option is broken on first render #109

Closed leo-cheron closed 3 years ago

leo-cheron commented 4 years ago

When watchCSS Flickity option is set to true, first render will ignore it and flickity carousel will be active instead of staying disabled. Proper behaviour is fixed by resizing the window.

I believe this is because flickity activate() method is called on componentDidUpdate(), even if it has never been activated before.

A possible fix could be to call activate() only if it was previously activated before (this.isActive === true).

juanvisbal commented 4 years ago

@mrgnou do you have a suggested workaround while the pull request is merged and reviewed? I'm having this same problem.

leo-cheron commented 4 years ago

@juanvisbalco You can have a look at my fork.