Skip to content

Warning: Can't perform a React state update on an unmounted component #3

@Muhammadinaam

Description

@Muhammadinaam

Very nice plugin.

I am rotating the cube with interval. following is my code:

useEffect(() => {
    let interval;
    if (props.autoRotateInterval)
      interval = setInterval(() => {
        if (carouselRef != null && carouselRef.current != null && isMounted) {
          carouselRef.current.next();
        }
      }, props.autoRotateInterval);

    return () => {
      carouselRef.current = null;
      clearInterval(interval);
    };
  }, []);

I am getting the following warning:

Warning: Can't perform a React state update on an unmounted component. This is a no-op, but it indicates a memory leak in your application. To fix, cancel all subscriptions and asynchronous tasks in the componentWillUnmount method.
in Motion (created by Carousel)
in div (created by Carousel)


I think Carousel is setting state without checking if it has been mounted or not.

Metadata

Metadata

Assignees

No one assigned

    Labels

    No labels
    No labels

    Projects

    No projects

    Milestone

    No milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions