Skip to content

Commit 4ebf889

Browse files
πŸ“ Add examples to docs.
1 parent 57c3797 commit 4ebf889

File tree

13 files changed

+96
-30
lines changed

13 files changed

+96
-30
lines changed

β€Ždocs/package-lock.jsonβ€Ž

Lines changed: 7 additions & 7 deletions
Some generated files are not rendered by default. Learn more about customizing how changed files appear on GitHub.

β€Ždocs/package.jsonβ€Ž

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -25,7 +25,7 @@
2525
"react": "^17.0.2",
2626
"react-dom": "^17.0.2",
2727
"react-icons": "^4.3.1",
28-
"react-idle-timer": "^5.5.0",
28+
"react-idle-timer": "^5.5.2",
2929
"remark": "^14.0.2",
3030
"remark-emoji": "^3.0.2",
3131
"remark-gfm": "^3.0.1",

β€Ždocs/pages/docs/about/changelog.mdxβ€Ž

Lines changed: 12 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -2,6 +2,18 @@
22
title: Changelog
33
description: IdleTimer Changelog
44
---
5+
### 5.5.2
6+
<Divider />
7+
8+
#### ✨ Enhancements
9+
- Add defaults to `IdleTimerComponent` generic typescript types.
10+
11+
### 5.5.1
12+
<Divider />
13+
14+
#### ✨ Enhancements
15+
- Cross-tab related methods will no longer throw an error if the manager is not ready yet. It will instead return `null`.
16+
517
## 5.5.0
618
<Divider />
719

β€Ždocs/pages/docs/api/idle-timer-provider.mdxβ€Ž

Lines changed: 10 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -30,7 +30,7 @@ and the `useIdleTimerContext` hook.
3030
```jsx
3131
import { IdleTimerProvider, useIdleTimerContext } from 'react-idle-timer'
3232

33-
export function Child (props) => {
33+
export function Child () {
3434
const idleTimer = useIdleTimerContext()
3535
return (
3636
<h1>{idleTimer.isIdle()}</h1>
@@ -203,7 +203,7 @@ To preserve types for your component's context, declare the type for the
203203
component's context property.
204204

205205
```tsx
206-
import { Component, ContextTypes } from 'react'
206+
import { Component, ContextType } from 'react'
207207
import { IIdleTimerContext, IdleTimerContext } from 'react-idle-timer'
208208

209209
export class Child extends Component<{}, {}> {
@@ -212,7 +212,7 @@ export class Child extends Component<{}, {}> {
212212
static contextType = IdleTimerContext
213213

214214
// Declare a type for context to preserve typescript types
215-
declare context: ContextType<IIdleTimerContext>
215+
context!: ContextType<typeof IIdleTimerContext>
216216

217217
render () {
218218
return (
@@ -221,3 +221,10 @@ export class Child extends Component<{}, {}> {
221221
}
222222
}
223223
```
224+
225+
## Examples
226+
227+
<Flex direction='column' mt={8}>
228+
<CodeSandboxButton name='functional-context-provider-jz4y77'>Functional Context Provider</CodeSandboxButton>
229+
<CodeSandboxButton name='class-context-provider-mfujuj'>Class Context Provider</CodeSandboxButton>
230+
</Flex>

β€Ždocs/pages/docs/api/use-idle-timer.mdxβ€Ž

Lines changed: 9 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -121,4 +121,12 @@ export const App = () => {
121121
}
122122
```
123123

124-
For more examples, see the [Features](/docs/features/idle-detection) section.
124+
## Examples
125+
126+
<Flex direction='column' mt={8}>
127+
<CodeSandboxButton name='idle-timer-hook-03790m'>Idle Detection</CodeSandboxButton>
128+
<CodeSandboxButton name='activity-detection-tmn5bp'>Activity Detection</CodeSandboxButton>
129+
<CodeSandboxButton name='cross-tab-2e1tbp'>Cross Tab Support</CodeSandboxButton>
130+
<CodeSandboxButton name='confirm-prompt-y8ew9s'>Confirm Prompt</CodeSandboxButton>
131+
<CodeSandboxButton name='presence-change-handler-2grrwh'>Presence Change Handler</CodeSandboxButton>
132+
</Flex>

β€Ždocs/pages/docs/api/with-idle-timer.mdxβ€Ž

Lines changed: 5 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -274,4 +274,8 @@ const element = document.getElementById('root')
274274
render(<Root />, element)
275275
```
276276

277-
For more examples, see the [Features](/docs/features) section.
277+
## Examples
278+
279+
<Flex direction='column' mt={8}>
280+
<CodeSandboxButton name='higher-order-component-9fyvnr'>Higher Order Component</CodeSandboxButton>
281+
</Flex>

β€Ždocs/pages/docs/features/activity-detection.mdxβ€Ž

Lines changed: 2 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -32,7 +32,5 @@ The methods associated with activity detection are:
3232
- [getElapsedTime](/docs/api/methods#getelapsedtime): Returns the ammount of milliseconds since the host component was mounted.
3333
{/* cspell:enable */}
3434

35-
### Examples
36-
37-
> Examples will be added once v5 is out of beta. For now you can check out the
38-
> simple examples in the [API](/docs/api/use-idle-timer) section.
35+
### Example
36+
<CodeSandbox name='activity-detection-tmn5bp' />

β€Ždocs/pages/docs/features/confirm-prompt.mdxβ€Ž

Lines changed: 2 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -26,7 +26,5 @@ The methods associated with the confirm prompt feature are:
2626
- [isPrompted()](/docs/api/methods#isprompted): Returns true if the prompt is displayed.
2727
{/* cspell:enable */}
2828

29-
### Examples
30-
31-
> Examples will be added once v5 is out of beta. For now you can check out the
32-
> simple examples in the [API](/docs/api/use-idle-timer) section.
29+
### Example
30+
<CodeSandbox name='confirm-prompt-y8ew9s' />

β€Ždocs/pages/docs/features/cross-tab.mdxβ€Ž

Lines changed: 2 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -31,7 +31,5 @@ The methods associated with the cross tab feature are:
3131
- [getTabId()](/docs/api/methods#gettabid): Returns the current tab's id.
3232
{/* cspell:enable */}
3333

34-
### Examples
35-
36-
> Examples will be added once v5 is out of beta. For now you can check out the
37-
> simple examples in the [API](/docs/api/use-idle-timer) section.
34+
### Example
35+
<CodeSandbox name='cross-tab-2e1tbp' />

β€Ždocs/pages/docs/features/idle-detection.mdxβ€Ž

Lines changed: 2 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -46,7 +46,5 @@ The methods associated with idle detection are:
4646
- [getTotalIdleTime](/docs/api/methods#gettotalidletime): Returns time in milliseconds the user was idle since the component mounted.
4747
{/* cspell:enable */}
4848

49-
### Examples
50-
51-
> Examples will be added once v5 is out of beta. For now you can check out the
52-
> simple examples in the [API](/docs/api/use-idle-timer) section.
49+
### Example
50+
<CodeSandbox name='idle-timer-hook-03790m' />

0 commit comments

Comments
Β (0)