I wanna add button, by clicking on which page will be scrolled back to the top with animation. I know how to realize that using JQuery. I tried this code:
import React, { Component } from 'react';
import $ from 'jquery';
import goUpNarrrowImage from '../static/img/goUpNarrow.png';
class GoTopButton extends Component {
constructor() {
super();
this.onclick = this.onclick.bind(this);
}
render() {
return (
<button>
<img src={goUpNarrrowImage} style={{
display: "inline-block",
marginRight: "10px"
}} />
наверх
</button>
);
}
onclick() {
$("html, body").animate({ scrollTop: 0 }, 1000);
}
}
export default GoTopButton;
But when I click the button nothing happens.