The above error frequently occurs with the following code
const [consumerMessages, setConsumerMesssages] = useState([])
const messagesEndRef = useRef(null);
const scrollToBottom = () => {
messagesEndRef.current.scrollIntoView({ behavior: "smooth" });
};
useEffect(() => {
scrollToBottom()
}, [consumerMessages]);
Following is the codesandbox link: https://codesandbox.io/s/sleepy-nobel-kt87m
Why this error is occuring and WHat could be the appropriate solution?