Open jektvik opened 14 hours ago
Yeah this was reported before: https://github.com/melloware/react-logviewer/issues/25 Any help debugging would be great
Pass, howver an eventual workaround that worked was to force rerender they entire component every time new data arrives. I use the key method for it:
useEffect(
...yourDataFetchingLogic
forceRerender()
...
,[yourDep])
...
const [key, setKey] = useState(0)
const forceRerender = () => {
setKey((prevKey) => prevKey + 1) // Increment key to force re-render
}
...
<MyTerminal key={key} logs={logs} />
The log scrolls to the bottom on first render. But after pushing additional lines to the log, it resets itself to the first line on subsequent rerenders and there doesn't seem to be any way of forcing him to follow the new lines pushed to the bottom. One thing that fixes it is to remove the ScrollFollow component, but then scrolling becomes jerky,
Here's my code which first loads a payload of logs lines on first render, and then pushes additional lines from a websocket channel (however the websocket is handled indepentently from the built-in logviewer api) .