Skip to content

Commit

Permalink
Add browser example to docs
Browse files Browse the repository at this point in the history
  • Loading branch information
axelrindle committed Jul 4, 2023
1 parent b094f4b commit 559ba1d
Show file tree
Hide file tree
Showing 2 changed files with 50 additions and 0 deletions.
4 changes: 4 additions & 0 deletions docs/docs/examples/03-browser/_category_.json
Original file line number Diff line number Diff line change
@@ -0,0 +1,4 @@
{
"label": "🌐 Browser",
"position": 3
}
46 changes: 46 additions & 0 deletions docs/docs/examples/03-browser/index.md
Original file line number Diff line number Diff line change
@@ -0,0 +1,46 @@
# Browser Usage

Version 3.1.0 introduced official browser support.

Visit [Browser Support](../../browser-support/) for more information.

## Basic Usage

```tsx
import { CheckResult } from '@version-checker/api'
import versionCheck from '@version-checker/browser'
import { useState } from 'react'
import { useQuery } from 'react-query'

export default function App() {
const { data } = useQuery<CheckResult['update'], any, CheckResult['update'], any>({
queryKey: ['updater'],
queryFn: async () => {
const { update } = await versionCheck({
owner: 'axelrindle',
repo: 'github-version-checker',
currentVersion: '1.2.3',
})

return update
}
})

return (
<p>
{data === undefined ?
(
<p>
No update found.
</p>
) :
(
<p>
<b>{data?.name}</b>
</p>
)
}
</p>
)
}
```

0 comments on commit 559ba1d

Please sign in to comment.