tjenkinson / dynamic-marquee-react

A `<Marquee />` component for React.
https://dynamic-marquee-react.tjenkinson.dev
Apache License 2.0
6 stars 4 forks source link

Marquee not change loop children when children is input and change value of input #287

Closed truongnc1 closed 3 weeks ago

tjenkinson commented 4 months ago

Sorry not really following. Would be great if you could provide an example on stackblitz? Could fork https://stackblitz.com/github/tjenkinson/dynamic-marquee/tree/master/demo?title=Dynamic%20Marquee%20Demo&file=src%2Fmain.ts

truongnc1 commented 4 months ago

with code: import * as React from 'react'; import { Marquee } from 'dynamic-marquee-react';

import './style.css';

export default function App() { const [counter, setCounter] = React.useState(0); const [items, setItems] = React.useState([1]);

React.useEffect(() => { const timer = setInterval(() => setCounter((a) => a + 1), 1000); return () => clearInterval(timer); }, []);

return (

setItems((pre) => pre.concat(1))}>Button
  <Marquee rate={0} startOnScreen>
    {items.map((item, index) => (
      <div>{index}</div>
    ))}
  </Marquee>
</div>

); }

item incorrect loop: 1 2 1 2 1 2. Please check for me!

tjenkinson commented 4 months ago

Hi @truongnc1

I am not sure what you are trying to do. The code doesn't actually run at all, as you can see here: https://stackblitz.com/edit/github-qnyo2f?file=src%2Fapp.tsx

tjenkinson commented 4 months ago

If you are able to share an example that shows your issue then I can help

truongnc1 commented 4 months ago

this code not return: 1 2 1 2 1 2. with rate = 0?

tjenkinson commented 4 months ago

The code you send doesn't run are you running something different?

But your problem might be that in the loop you're returning the index not the item