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

panicked at 'called Option::unwrap() on a None value' > /packages/core/src/scopes.rs:172:48 #179

Closed
t1m0t opened this issue Jan 29, 2022 · 7 comments · Fixed by #182
Closed

Comments

@t1m0t
Copy link
Contributor

t1m0t commented Jan 29, 2022

After clicking to trigger push_route, I get this runtime error.

panicked at 'called Option::unwrap() on a None value', /home/user/packages/core/src/scopes.rs:172:48

Looks like we should handle the None variant here.

Environment:

  • Dioxus version: master
  • Rust version: 1.58.1
  • OS info: Debian 11
  • App platform: web
  • On: runtime
@autarch
Copy link
Contributor

autarch commented Jan 29, 2022

@jkelleyrtp I think this is the error I was seeing yesterday.

@t1m0t Can you try the latest HEAD? I think this may already be fixed.

@t1m0t
Copy link
Contributor Author

t1m0t commented Jan 29, 2022

@autarch I'm on the master branch and did cargo update. Same error here.

@jkelleyrtp
Copy link
Member

Can you save the code that triggered this in a branch somewhere? Getting an error with unwrap here means the diffing algorithm scheduled a node for deletion even if it was still active, which shouldn't be happening.

@t1m0t
Copy link
Contributor Author

t1m0t commented Jan 29, 2022

Can you save the code that triggered this in a branch somewhere? Getting an error with unwrap here means the diffing algorithm scheduled a node for deletion even if it was still active, which shouldn't be happening.

I'll have to figure it out.
Could it relates to this kind error log I get before?

ERROR /home/user/packages/core/src/nodes.rs:626 
                Warning: Each child in an array or iterator should have a unique "key" prop.
                Not providing a key will lead to poor performance with lists.
                See docs.rs/dioxus for more information.
                -------------

@jkelleyrtp
Copy link
Member

jkelleyrtp commented Jan 29, 2022

Can you save the code that triggered this in a branch somewhere? Getting an error with unwrap here means the diffing algorithm scheduled a node for deletion even if it was still active, which shouldn't be happening.

I'll have to figure it out. Could it relates to this kind error log I get before?

ERROR /home/user/packages/core/src/nodes.rs:626 
                Warning: Each child in an array or iterator should have a unique "key" prop.
                Not providing a key will lead to poor performance with lists.
                See docs.rs/dioxus for more information.
                -------------

Perhaps? It's always a good idea to put your keys in anyways, and I think the traceback (if you hunt for it) should tell you which line of code is causing the error.

The Router pushes the diffing algorithm in a weird way since it sees nodes but can't distinguish if the current scope created them, or some parent.

I think it has something to do with memoization in these nested chains. Introduced by #67

@t1m0t
Copy link
Contributor Author

t1m0t commented Jan 29, 2022

My issue is that I pass several children in a parent Element (&cx.props.children) I think.
I believe we should disallow passing several children because actually Dioxus doesn't handle that properly. Instead of having your app to certainly crash using this anti pattern, it would be better to simply disallow it. A log error is not enough imo.

This would force us to find another way. Avoid using children anti pattern for a complex structure is doable, ain't it? What would be the alternative pattern then? In vuejs, this kind of children pattern is named slot. In React, idk.

@jkelleyrtp
Copy link
Member

My issue is that I pass several children in a parent Element (&cx.props.children) I think. I believe we should disallow passing several children because actually Dioxus doesn't handle that properly. Instead of having your app to certainly crash using this anti pattern, it would be better to simply disallow it. A log error is not enough imo.

This would force us to find another way. Avoid using children anti pattern for a complex structure is doable, ain't it? What would be the alternative pattern then? In vuejs, this kind of children pattern is named slot. In React, idk.

The intention is that this feature works :) Getting it right is somewhat difficult because everything is a self-referential structure. If you have a minimal repro I could start there and add some more test coverage to fix the issue. We have a few tests covering children elements already, but I guess they're not complex enough to catch the failing cases.

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 a pull request may close this issue.

3 participants