2 * Copyright © 2018 European Support Limited
4 * Licensed under the Apache License, Version 2.0 (the "License");
5 * you may not use this file except in compliance with the License.
6 * You may obtain a copy of the License at
8 * http://www.apache.org/licenses/LICENSE-2.0
10 * Unless required by applicable law or agreed to in writing, software
11 * distributed under the License is distributed on an "AS IS" BASIS,
12 * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
13 * See the License for the specific language governing permissions and
14 * limitations under the License.
17 import React from 'react';
18 import PropTypes from 'prop-types';
19 import PerfectScrollbar from 'perfect-scrollbar';
21 class Scrollbars extends React.Component {
22 containerRef = React.createRef();
26 const container = this.containerRef.current;
28 this.scrollbars = new PerfectScrollbar(container);
31 componentDidUpdate() {
32 if (this.scrollbars) {
33 this.scrollbars.update();
37 componentWillUnmount() {
38 this.scrollbars.destroy();
39 this.scrollbars = null;
43 const { children, className } = this.props;
46 <div className={className} ref={this.containerRef}>
53 Scrollbars.propTypes = {
54 children: PropTypes.node,
55 className: PropTypes.string
58 export default Scrollbars;