Skip to content
This repository has been archived by the owner on Jul 5, 2021. It is now read-only.

Commit

Permalink
Simpler boolean being returned
Browse files Browse the repository at this point in the history
  • Loading branch information
donovanh committed Feb 12, 2019
1 parent 4894613 commit 50bcbfe
Show file tree
Hide file tree
Showing 4 changed files with 8 additions and 10 deletions.
4 changes: 1 addition & 3 deletions src/hooks/online.js
Original file line number Diff line number Diff line change
Expand Up @@ -23,7 +23,5 @@ export function useOnline() {
}
}, [])

return {
online
}
return online
}
6 changes: 3 additions & 3 deletions storybook/stories/online/README.md
Original file line number Diff line number Diff line change
Expand Up @@ -11,10 +11,10 @@ import { useOnline } from '@nearform/react-browser-hooks'
Example of usage:

```javascript
const { online } = useOnline()
const online = useOnline()
<p>Status: {online ? 'online' : 'offline'}</p>
```

Returns an object containing:
Returns:

- status (boolean): whether online or not
- online (boolean): whether online or not
2 changes: 1 addition & 1 deletion storybook/stories/online/online.stories.js
Original file line number Diff line number Diff line change
Expand Up @@ -5,7 +5,7 @@ import { useOnline } from '../../../src'
import readme from './README.md'

function Online() {
const { online } = useOnline()
const online = useOnline()
return (
<div>
<h2>Online Demo</h2>
Expand Down
6 changes: 3 additions & 3 deletions test/unit/hooks/online.unit.test.js
Original file line number Diff line number Diff line change
Expand Up @@ -17,7 +17,7 @@ describe('useOnline', () => {

onLineGetter.mockReturnValue(true)

testHook(() => ({ online } = useOnline()))
testHook(() => (online = useOnline()))

expect(online).toBe(true)
})
Expand All @@ -28,7 +28,7 @@ describe('useOnline', () => {
onLineGetter.mockReturnValue(false)

act(() => {
testHook(() => ({ online } = useOnline()))
testHook(() => (online = useOnline()))
})

onLineGetter.mockReturnValue(true)
Expand All @@ -53,7 +53,7 @@ it('updates state on "offline"', () => {
onLineGetter.mockReturnValue(true)

act(() => {
testHook(() => ({ online } = useOnline()))
testHook(() => (online = useOnline()))
})

onLineGetter.mockReturnValue(false)
Expand Down

0 comments on commit 50bcbfe

Please sign in to comment.