Skip to content

Commit

Permalink
fix: type
Browse files Browse the repository at this point in the history
  • Loading branch information
jpwallace22 committed Dec 9, 2023
1 parent 0b08c0b commit ec7666d
Show file tree
Hide file tree
Showing 2 changed files with 11 additions and 6 deletions.
2 changes: 1 addition & 1 deletion docs/src/content/docs/hooks/useWorkerState.mdx
Original file line number Diff line number Diff line change
Expand Up @@ -3,7 +3,7 @@ title: useWorkerState()
description: A hook that exposes a web worker as a function and returns state
---

import { UseWorkerState } from '../../../components/useWorkerState';
import { UseWorkerState } from '../../../components/UseWorkerState';

## Overview

Expand Down
15 changes: 10 additions & 5 deletions use-react-workers/README.md
Original file line number Diff line number Diff line change
Expand Up @@ -68,9 +68,14 @@ const MyCoolComponent = () => {
};

return (
<button type="button" onClick={handleClick}>
Run Fibonacci
</button>
<div className="flex gap-4">
<button type="button" onClick={handleClick}>
With Worker
</button>
<button type="button" onClick={handleClick}>
Without Worker
</button>
</div>
);
};
```
Expand Down Expand Up @@ -103,7 +108,7 @@ const MyCoolComponent = () => {

```tsx
import React from 'react';
import { useWorkerState } from 'use-react-workers';
import { useWorker } from 'use-react-workers';

// Long running function that we dont want blocked
export const countByInput = (countBy: 1 | 2 | 5) => {
Expand All @@ -117,7 +122,7 @@ export const countByInput = (countBy: 1 | 2 | 5) => {
const MyCoolComponent = () => {
const timer = useWorker(countByInput); // Will not block the main thread

timer.onMessage({ data } => console.log(data));
timerWorker.onMessage(({ data }) => setCount(data));

return (
<div>
Expand Down

0 comments on commit ec7666d

Please sign in to comment.