Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

fix(Carousel): can't give dynamic children to Carousel #1469

Open
2 tasks done
kage1020 opened this issue Aug 16, 2024 · 0 comments
Open
2 tasks done

fix(Carousel): can't give dynamic children to Carousel #1469

kage1020 opened this issue Aug 16, 2024 · 0 comments

Comments

@kage1020
Copy link

  • I have searched the Issues to see if this bug has already been reported
  • I have tested the latest version

Steps to reproduce

Create dynamic children Carousel component like below:

function App() {
  const [count, setCount] = useState(0);
  return (
    <div className="bg-gray-800 w-screen h-screen">
      <Button onClick={() => setCount((p) => p + 1)}>count: {count}</Button>
      <Carousel>
        <img src={viteLogo} className="logo" alt="Vite logo" />
        <img src={reactLogo} className="logo" alt="React logo" />
        {count < 5 && <img src={viteLogo} className="logo" alt="Vite logo" />}
      </Carousel>
    </div>
  );
}

Then, count up to 5 by clicking button

Current behavior

Flowbite throws error of TypeError: Cannot read properties of null (reading 'props') because it try to get child.props.className in this code.

Expected behavior

Skip processing Falsy values.

Context

Live Preview: https://stackblitz.com/edit/vitejs-vite-fynok7?file=src%2FApp.tsx

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

No branches or pull requests

1 participant