Enclose your useEffect() function inside $(document).ready() so that useEffect is executed only after all libraries and the page is loaded