react-native-root-toast icon indicating copy to clipboard operation
react-native-root-toast copied to clipboard

null is not an object(evaluting '_this._root_setNativeProps')

Open combing520 opened this issue 8 years ago • 2 comments

null is not an object(evaluting '_this._root_setNativeProps') ,当按下 回退键(android)的就会出现该错误。我的 RN 版本为 0.42

combing520 avatar Mar 20 '17 06:03 combing520

在源文件中改下代码就好了, 在lib/ToastContainer.js 128行 componentWillUnmount = () => { this._root&&this._hide(); };

zhaogao avatar Apr 07 '17 04:04 zhaogao

Was getting this when running on react native web and heres the relevant part of the patch I'm using

     componentWillUnmount = () => {
-        this._hide();
+        this._root && this._hide();
         this.dimensionListener?.remove();
         this.keyboardListener?.remove();
     };
@@ -172,9 +174,11 @@ class ToastContainer extends Component {
         if (!this._animating) {
             clearTimeout(this._hideTimeout);
             this._animating = true;
-            this._root.setNativeProps({
+            if(this._root && this._root.setNativeProps){
+              this._root.setNativeProps({
                 pointerEvents: 'auto'
-            });
+              });
+            }
             this.props.onShow && this.props.onShow(this.props.siblingManager);
             Animated.timing(this.state.opacity, {
                 toValue: this.props.opacity,
@@ -197,7 +201,7 @@ class ToastContainer extends Component {
         clearTimeout(this._showTimeout);
         clearTimeout(this._hideTimeout);
         if (!this._animating) {
-            if (this._root) {
+            if (this._root && this._root.setNativeProps) {
                 this._root.setNativeProps({
                     pointerEvents: 'none'
                 });

basically just a check around every setNativeProps

dannyhw avatar Jul 19 '23 22:07 dannyhw