Skip to content

fix: add null check before accessing props#19

Open
blabute wants to merge 1 commit intoTheSpicyMeatball:mainfrom
blabute:fix/null-reference
Open

fix: add null check before accessing props#19
blabute wants to merge 1 commit intoTheSpicyMeatball:mainfrom
blabute:fix/null-reference

Conversation

@blabute
Copy link
Copy Markdown

@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
Copy Markdown
Author

blabute commented Oct 31, 2022

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

@alleksei37
Copy link
Copy Markdown

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

@alleksei37
Copy link
Copy Markdown

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
Copy Markdown
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
Copy Markdown
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