Skip to content

Conversation

pawan52tiwari
Copy link

Current ToastContainer.js class can only render Text elements We can use View as a container if the child is not a text to render react component.

Current ToastContainer.js class can only render Text elements We can use View as a container if the child is not a text to render react component.
@pawan52tiwari
Copy link
Author

@magicismight Can you please review this cr

@brownbl1
Copy link

To avoid using the forked package, I used patch-package to generate this diff and apply it on npm install.

diff --git a/node_modules/react-native-root-toast/lib/ToastContainer.js b/node_modules/react-native-root-toast/lib/ToastContainer.js
index a645d4d..0f03cc9 100644
--- a/node_modules/react-native-root-toast/lib/ToastContainer.js
+++ b/node_modules/react-native-root-toast/lib/ToastContainer.js
@@ -255,13 +255,13 @@ class ToastContainer extends Component {
                     pointerEvents="none"
                     ref={ele => this._root = ele}
                 >
-                    <Text style={[
+                    {typeof this.props.children === 'string' ? <Text style={[
                         styles.textStyle,
                         props.textStyle,
                         props.textColor && {color: props.textColor}
                     ]}>
                         {this.props.children}
-                    </Text>
+                    </Text> : this.props.children}
                 </Animated.View>
             </TouchableWithoutFeedback>
         </View> : null;

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

2 participants