I have enjoyed using this library in a couple of projects and think that it's great! Recently I have come across an issue though.
This time around, my use case involves adding items to the news ticker dynamically but I am unsure how to get this to work.
import React, { useEffect, useState } from "react";
import NewsTicker from "react-advanced-news-ticker";
export default function App() {
const [items, setItems] = useState([]);
useEffect(() => {
setTimeout(() => {
// simulate API request
setItems(["Item 1", "Item 2", "Item 3"]);
}, 3000);
}, []);
return (
<NewsTicker maxRows={1}>
<div>Hello</div>
<div>Goodbye</div>
{items.map((i) => (
<div key={i}>{i}</div>
))}
</NewsTicker>
);
}
In this example, only the "Hello" and "Goodbye" strings are displayed in the ticker. If I add only the dynamic portions and remove the hard coded "Hello" and "Goodbye" divs, the page refuses to load with an error from the library.
Is there a way I can dynamically add/remove data from the items in the ticker? I have looked through the documentation and cannot find a way of doing it. Apologies if it is something I have overlooked and indeed is documented somewhere.
Thanks.