I'm trying to use jquery.scrollto on my react app but cannot seem to use it correctly.
I installed it via npm
>npm install jquery.scrollto
+ jquery.scrollto@2.1.2
added 1 package in 5.316s
but when I try to use it I get a typeError
Uncaught TypeError: $(...).scrollTo is not a function
Here's the code inside the application :
var $ = require('jquery')
require('jquery.scrollto')
$('#home').on('click',function(){
$(window).scrollTo('#home', 1000);
})
and here's my package.json :
{
"name": "portfolio",
"version": "0.1.0",
"private": true,
"dependencies": {
"jquery": "^3.3.1",
"jquery.scrollto": "^2.1.2",
"react": "^16.4.2",
"react-dom": "^16.4.2",
"react-scripts": "1.1.5"
},
"scripts": {
"start": "react-scripts start",
"build": "react-scripts build",
"test": "react-scripts test --env=jsdom",
"eject": "react-scripts eject"
}
}
Am I missing something ? Thanks a lot.