Skip to content

Element type is invalid: expected a string (for built-in components) or a class/function... #2206

Open
@PremaYT

Description

@PremaYT

I am using react-slick as a dependency in one of my custom react package. Slider works fine in the component whereas it throws below error when we publish the component as a package and use it in another component.

Error :

Element type is invalid: expected a string (for built-in components) or a class/function (for composite components) but got: object. Check the render method 'SimpleSlider'.

import Slider from "react-slick";

const SimpleSlider = () => {
    const settings = {
      dots: true,
      infinite: true,
      speed: 500,
      slidesToShow: 1,
      slidesToScroll: 1
    }
    return (
      <div>
        <Slider {...settings}>
          <div>
            <h3>1</h3>
          </div>
          <div>
            <h3>2</h3>
          </div>
          <div>
            <h3>3</h3>
          </div>
          <div>
            <h3>4</h3>
          </div>
          <div>
            <h3>5</h3>
          </div>
          <div>
            <h3>6</h3>
          </div>
        </Slider>
      </div>
    );
}

export default SimpleSlider;

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