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

applyStyle doesn't check null or undefined cases #128

Open
fluiddot opened this issue Oct 22, 2019 · 2 comments
Open

applyStyle doesn't check null or undefined cases #128

fluiddot opened this issue Oct 22, 2019 · 2 comments

Comments

@fluiddot
Copy link

I spotted that if you have a render rule that potentially returns null or undefined and you use applyStyle in other rule it could produce an exception.

Here is my case:
I don't want to render anything when I have softbreak in the markdown but for textgroup items, depending on the children I have to render a View or a Text. Besides when I have to render a View in a textgroup item I need to use applyStyle for styling possible texts inside.

In this case when applyStyle is called it tries to get type of the null child and crashes.

if (child.type.displayName === type) {
return <Text key={child.key} {...child.props} style={[].concat(child.props.style, styles)} />;
}

@iamacup
Copy link

iamacup commented Nov 12, 2019

Hey, i removed applyStyles here iamacup#32 in the react-native-markdown-display fork.

This was possible because of the change here: iamacup@e0b726c

@fluiddot
Copy link
Author

Thanks @iamacup, I’ll take a look to your fork (nice work btw).

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

No branches or pull requests

2 participants