Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Adding support for rendering React component #131

Open
wants to merge 2 commits into
base: master
Choose a base branch
from

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