Jquery in React is not defined
Try add jQuery
to your project, like
npm i jquery --save
or if you use bower
bower i jquery --save
then
import $ from 'jquery';
I just want to receive ajax request, but the problem is that jQuery is not defined in React.
Then don't use it. Use Fetch and have a look at Fetch polyfill in React not completely working in IE 11 to see example of alternative ways to get it running
Something like this
const that = this; fetch('http://jsonplaceholder.typicode.com/posts') .then(function(response) { return response.json(); }) .then(function(myJson) { that.setState({data: myJson}); // for example });
It happens mostly when JQuery
is not installed in your project.Install JQuery in your project by following commands according to your package manager.
Yarn
yarn add jquery
npm
npm i jquery --save
After this just import $
in your project file.import $ from 'jquery'