brainhubeu / react-carousel

A pure extendable React carousel, powered by Brainhub (craftsmen who ❤️ JS)

Home Page:https://brainhub.eu/

Geek Repo:Geek Repo

Github PK Tool:Github PK Tool

Cannot update a component while rendering a different component. Probably due to bad setState()

tramax opened this issue · comments

Describe the bug
React issues a warning about bad setState when the Carousel component is used

To Reproduce
Steps to reproduce the behavior:

  1. Install 10.2.0
  2. Install react-carousel 2.0.3
  3. Dynamic import the carousel component like so (as NextJS SSR crashes using normal import)
import dynamic from 'next/dynamic';

const Carousel = dynamic(
  () => import('@brainhubeu/react-carousel'),
  { ssr: false },
);
  1. Use the carousel
  2. See error in Chrome console

Expected behavior
A clear and concise description of what you expected to happen.

Screenshots
image

Environment

System:
    OS: Windows 10 10.0.19042
    CPU: (4) x64 Intel(R) Core(TM) i5-7600 CPU @ 3.50GHz  
    Memory: 1.43 GB / 7.94 GB
  Binaries:
    Node: 16.0.0 - C:\Program Files\nodejs\node.EXE       
    npm: 7.10.0 - C:\Program Files\nodejs\npm.CMD
  Browsers:
    Chrome: 90.0.4430.212
    Edge: Spartan (44.19041.906.0), Chromium (90.0.818.56)
    Internet Explorer: 11.0.19041.1
  npmPackages:
    @brainhubeu/react-carousel: 2.0.3 => 2.0.3
commented

@tramax Were you able to fix this error?

Facing the same issue

@tramax Were you able to fix this error?

@kb1995 unfortunately not yet 😄 do you face the same problem with NextJS or another stack?

Same issue... this is a critical bug, make this lib gargbage

I got this working by used the source and removing all the scss imports as they were bugging in my build environment. Simple import of the index.js file from the src directory here https://github.com/brainhubeu/react-carousel/tree/master/react-carousel/src and the errors about setState were resolved.

I got this working by used the source and removing all the scss imports as they were bugging in my build environment. Simple import of the index.js file from the src directory here https://github.com/brainhubeu/react-carousel/tree/master/react-carousel/src and the errors about setState were resolved.

Hi Shaun. Do you use dynamic import via 'next/dynamic'? Would you be able to post a screenshot or a snippet of your code? Thank you

Hi, sorry I abandoned this in favor of https://github.com/akiran/react-slick that just seems to work our of the box