From 3c0801a7e875f12fa943075d26400450a71d6dcc Mon Sep 17 00:00:00 2001 From: rookie125 <964379494@qq.com> Date: Thu, 28 Nov 2019 15:53:56 +0800 Subject: [PATCH] fix: Fixed infinite execution of the scrollbar component componentDidUpdate hook function --- src/scrollbar/Scrollbar.jsx | 12 ++++++------ 1 file changed, 6 insertions(+), 6 deletions(-) diff --git a/src/scrollbar/Scrollbar.jsx b/src/scrollbar/Scrollbar.jsx index 033f638ec..ac383db08 100644 --- a/src/scrollbar/Scrollbar.jsx +++ b/src/scrollbar/Scrollbar.jsx @@ -34,17 +34,17 @@ export class Scrollbar extends Component { } } - componentDidUpdate() { + componentDidUpdate(prevProps) { + const { noresize } = this.props; + this.resizeDom = ReactDOM.findDOMNode(this.refs.resize) - if (!this.props.noresize){ + + if (!noresize && prevProps.noresize !== noresize) { this.cleanResize && this.cleanResize(); addResizeListener(this.resizeDom, this.update) - this.cleanResize = ()=>{ - removeResizeListener(this.resizeDom, this.update); - } + this.cleanResize = () => removeResizeListener(this.resizeDom, this.update); } } - componentWillUnmount(){ this.cleanRAF();