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

fix: add null check before accessing props #19

Open
wants to merge 1 commit into
base: main
Choose a base branch
from

Conversation

blabute
Copy link

@blabute blabute commented Oct 24, 2022

This corrects null reference error when a child is null/undefined (which is valid).

Closes 18.

This corrects null reference error when a child is null/undefined (which is valid).

Closes 18.
@blabute
Copy link
Author

blabute commented Oct 31, 2022

@TheSpicyMeatball curious your thoughts on this when you get a chance!

@alleksei37
Copy link

Getting the same error:
TypeError: Cannot read properties of undefined (reading 'props') when one of the child nodes is undefined.

@alleksei37
Copy link

alleksei37 commented Oct 31, 2022

Found a temporary fix/workaround - wrap the node which contains a possible undefined value in a fragment component. For example:
<>{value && <p>{value}</p>}</>

@blabute
Copy link
Author

blabute commented Oct 31, 2022

Found a temporary fix/workaround - wrap the node which contains a possible undefined value in a fragment component. For example: <>{value && <p>{value}</p>}</>

Thanks for the suggestion! It definitely works but since the offending code is valid jsx, I think the repo should be updated to handle it.

@blabute
Copy link
Author

blabute commented Nov 1, 2022

@alleksei37, I shared this message on the initial issue in case you are looking for alternatives.

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