Skip to content
This repository has been archived by the owner on May 19, 2023. It is now read-only.

Commit

Permalink
Create newState instead of passing in object directly
Browse files Browse the repository at this point in the history
  • Loading branch information
chloe authored Apr 15, 2021
1 parent ae723c0 commit 47ec01b
Showing 1 changed file with 2 additions and 2 deletions.
4 changes: 2 additions & 2 deletions src/component.ts
Original file line number Diff line number Diff line change
Expand Up @@ -26,11 +26,11 @@ export class Component {
typeof el === 'string'
? document.querySelector<HTMLElement>(el) || document.body
: (el as HTMLElement);
const $render = (deps: string[] = Object.keys(this.state)) => this.render(deps);
const newState = { ...this.state, $render: this.render.bind(this) };

this.ast = compile(rootEl, this.state);
this.directives = { ...this.directives, ...directives };
this.state = reactive({ ...this.state, $render }, this.render.bind(this), this.watchers);
this.state = reactive(newState, this.render.bind(this), this.watchers);

this.render();

Expand Down

0 comments on commit 47ec01b

Please sign in to comment.