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

useContext el.update twice? #246

Open
windmaomao opened this issue May 12, 2021 · 0 comments
Open

useContext el.update twice? #246

windmaomao opened this issue May 12, 2021 · 0 comments

Comments

@windmaomao
Copy link

windmaomao commented May 12, 2021

just curious if this is true when consumer component is displayed, it'll render twice ?

The reason i'm having this question is that by reading

const useContext = hook(class extends Hook {
  call() {
    if(!this._ranEffect) {
      this._ranEffect = true;
      if(this._unsubscribe) this._unsubscribe();
      this._subscribe(this.Context);
      this.el.update();
    }
  }

I wonder if call is called after the update, and then inside there's a second el.update.

For the withProviderValue test, i put console.log all all stages, i got the following,

...set value
render
constructor
update
_subscribe
value 3
call
_subscribe
value 3
render
update
call
teardown

I'm convinced that the effect does trigger second render which calls to subscribe again. Could you share a bit insight on what is the reason to add that extra effect ? thank you.

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

No branches or pull requests

1 participant