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

refactor: Change syntax to support closers capturing variables #140

Merged
merged 8 commits into from
Jan 25, 2022

Conversation

mhevery
Copy link
Contributor

@mhevery mhevery commented Jan 24, 2022

Change syntax from:

const Counter = qComponent<{}, {count: number}>({
  onMount: qHook(() => {count: 0}),
  onRender: qHook((props, state) => (
    <button on:click={qHook<typeof Counter>((props, state) => state.count++)}>
      {state.count}
    </button>
  )
});

to:

const Counter = qComponent<>(() => {
  const state = useState();
  return onRender(() => (
    <button on:click={() => state.count++)}>
      {state.count}
    </button>
  )
});

@mhevery mhevery force-pushed the pr-feat-use-closure branch 2 times, most recently from eb0546a to 48d84ea Compare January 24, 2022 17:55
mhevery and others added 2 commits January 24, 2022 14:21
Change syntax from:
```typescript
const Counter = qComponent<{}, {count: number}>({
  onMount: qHook(() => {count: 0}),
  onRender: qHook((props, state) => (
    <button on:click={qHook<typeof Counter>((props, state) => state.count++)}>
      {state.count}
    </button>
  )
});
```
to:
```typescript
const Counter = qComponent<>(() => {
  const state = useState();
  return onRender(() => (
    <button on:click={() => state.count++)}>
      {state.count}
    </button>
  )
});
```

Co-authored-by: Adam Bradley <adamdbradley@users.noreply.github.com>
Co-authored-by: Manu MA <manu.mtza@gmail.com>
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 this pull request may close these issues.

2 participants