Skip to content

useContext el.update twice? #246

Open
@windmaomao

Description

@windmaomao

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.

Metadata

Metadata

Assignees

No one assigned

    Labels

    No labels
    No labels

    Projects

    No projects

    Milestone

    No milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions