react-native-root-toast
react-native-root-toast copied to clipboard
null is not an object(evaluting '_this._root_setNativeProps')
null is not an object(evaluting '_this._root_setNativeProps') ,当按下 回退键(android)的就会出现该错误。我的 RN 版本为 0.42
在源文件中改下代码就好了, 在lib/ToastContainer.js 128行 componentWillUnmount = () => { this._root&&this._hide(); };
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