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

render called before sub-component's views get to the DOM (this is a regression) #1358

Closed
1 of 4 tasks
ctm opened this issue Jun 30, 2020 · 3 comments · Fixed by #1360
Closed
1 of 4 tasks

render called before sub-component's views get to the DOM (this is a regression) #1358

ctm opened this issue Jun 30, 2020 · 3 comments · Fixed by #1360
Labels

Comments

@ctm
Copy link
Contributor

ctm commented Jun 30, 2020

Problem
If a component has a sub-component, under yew 16.0.2, the top-level's render would only be called after the sub-component's view was created and made available to the DOM. That changed with 17.0.

Steps To Reproduce
Steps to reproduce the behavior:

  1. I've created a render_sooner_demo branch that has the following steps in it (in examples/custom_components)
  2. Add log and wasm-logger to Cargo.toml
  3. Add a render method that calls info! to some top-level Component
  4. Add a call to info! in the view method of the sub-component
  5. Run the app and look at the console output

Expected behavior
In yew 16.0.2 (and previous versions that had render), the info! line would be produced after the info! line for any views from any sub-components. Now it's produced before. That means that a top-level render method can't rely on accessing DOM elements that are created by sub-components.

I have never done any React programming, so I don't know if the new behavior should be considered a bug, but it is definitely surprising and has me momentarily not switching to yew 17.0, although I could add some code to make the sub-component send a message up to the parent after its render has been called.

Screenshots
Here's what happens with 17.0:
Screen Shot 2020-06-30 at 14 07 32

Here's what happens with 16.2:
Screen Shot 2020-06-30 at 14 09 47

Environment:

  • Yew version: v0.17
  • Rust version: rustc 1.44.1 (c7087fe00 2020-06-17)
  • Target, if relevant: whatever examples/build.sh uses
  • Build tool, if relevant: examples/build.sh

Questionnaire

  • I'm interested in fixing this myself but don't know where to start
  • I would like to fix and I have a solution
  • I don't have time to fix this right now, but maybe later
  • I don't know that this is.a bug, but if it is, I'm willing to help
@ctm ctm added the bug label Jun 30, 2020
@jstarry
Copy link
Member

jstarry commented Jul 1, 2020

This is indeed a regression, thanks for the report. I'll make sure this gets fixed in a patch release

@jstarry
Copy link
Member

jstarry commented Jul 1, 2020

Thanks again @ctm! Can you confirm that 0.17.1 fixes your issue?

@ctm
Copy link
Contributor Author

ctm commented Jul 1, 2020

It does indeed. I've tested it locally and am pushing to production now.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
Projects
None yet
Development

Successfully merging a pull request may close this issue.

2 participants