In my app I import jquery in my index.js and save it on window in order to make it global like this:
import React from 'react';
import ReactDOM from 'react-dom';
import App from './App';
import $ from "jquery/dist/jquery.slim.min";
import bootstrap from 'bootstrap/dist/js/bootstrap.min'
window.jQuery = window.$ = $;
ReactDOM.hydrate(<App />, document.getElementById('root'));
On another file i'm trying to use jquery in this way:
useEffect(() => {
const audio = document.getElementById("player");
const popover = <div>bla bla bla</div>
$('#player').popover({title: popover, html: true, placement: "bottom"});
})
but I get an error that '$' is not defined. Why it isn't becoming global?