From dccdd2476790ea795dcbc5fc39ce27abebebbd35 Mon Sep 17 00:00:00 2001 From: Ilya Akhmadullin Date: Wed, 21 Oct 2020 09:20:50 +0300 Subject: [PATCH] fix: allow update disabled prop at runtime --- src/react-sortable.tsx | 5 +++++ 1 file changed, 5 insertions(+) diff --git a/src/react-sortable.tsx b/src/react-sortable.tsx index 81dd0f5..f8546d0 100644 --- a/src/react-sortable.tsx +++ b/src/react-sortable.tsx @@ -71,6 +71,11 @@ Please read the updated README.md at https://github.com/SortableJS/react-sortabl const newOptions = this.makeOptions(); Sortable.create(this.ref.current, newOptions); } + componentDidUpdate(prevProps: ReactSortableProps): void { + if (prevProps.disabled !== this.props.disabled && this.sortable) { + this.sortable.option("disabled", this.props.disabled); + } + }; render(): JSX.Element { const { tag, style, className, id } = this.props;