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

Support Lazy nodes from V2 #16

Merged
merged 1 commit into from
May 13, 2020
Merged

Conversation

kwasniew
Copy link
Contributor

Types of changes

  • Bug fix (non-breaking change which fixes an issue)
  • New feature (non-breaking change which adds functionality)
  • Breaking change (fix or feature that would cause existing functionality to change)

Checklist:

  • My code follows the code style of this project.
  • My change requires a change to the documentation.
  • I have updated the documentation accordingly.
  • I have read the CONTRIBUTING document.
  • I have added tests to cover my changes.
  • All new and existing tests passed.

Copy link
Member

@frenzzy frenzzy left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Nice one, thanks!

src/index.js Outdated

if (node != null && typeof node !== 'boolean') {
if (node.type === 2 && node.lazy) {
Copy link
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Are you sure we need both checks, can't we leave only one?

Copy link
Contributor Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

I was thinking about it myself and decided to take a defensive approach here. I couldn't think of a scenerio where only one of the 2 would be present though. If we're to leave only one do you prefer the node.type === 2? You already have node.type === 3 check in the code.

src/index.js Outdated
Comment on lines 248 to 250
if (node.type === 2 && node.lazy) {
node = node.lazy.view(node.lazy)
}
Copy link
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Shouldn't this part be inside resolveNode function so it will resolve any Lazy components recursively?
Would be cool to have a test for nested Lazy.

Copy link
Contributor Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Good catch! This place didn't feel right to me. It's so much cleaner in the resolveNode function. Will send an updated PR in a sec.

Copy link
Contributor Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Totally agree on the test for the nested lazy! I will add it.

Copy link
Contributor Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

I've just checked and interestingly HA2 doesn't support nested lazy. But since it doesn't cost us anything to add it here I'd leave the nested lazy support.

Copy link
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Actually there was a problem not just with nested Lazy({ render: Lazy({...}) }) but also with using functional components inside Lazy view Lazy({ render: Component }).
I think we are good now. I will create a new release later today. Thank you!

@kwasniew
Copy link
Contributor Author

Let me know if you have any comments to the new version.

@frenzzy frenzzy merged commit 54f7e89 into kriasoft:master May 13, 2020
@frenzzy
Copy link
Member

frenzzy commented May 14, 2020

Just released under v3.2.0 🎉 thanks again.

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