Skip to content

Commit

Permalink
chore: examples tweak
Browse files Browse the repository at this point in the history
  • Loading branch information
simoneb committed Jan 4, 2021
1 parent c6d56dc commit ec5f6c0
Showing 1 changed file with 4 additions and 2 deletions.
6 changes: 4 additions & 2 deletions examples/components/Persistence.js
Original file line number Diff line number Diff line change
Expand Up @@ -6,7 +6,7 @@ function makeStateHookFactory(prefix) {

return function useSessionStorageState(initializer) {
const result = useState(
JSON.parse(sessionStorage.getItem(id) || 'null') || initializer
JSON.parse(sessionStorage.getItem(id) || 'null') ?? initializer
)

const [state] = result
Expand All @@ -20,6 +20,8 @@ function makeStateHookFactory(prefix) {
}
}

const stateHookFactory = makeStateHookFactory('persistence')

function Persistence() {
const {
currentToken,
Expand All @@ -34,7 +36,7 @@ function Persistence() {
defaultPageNumber: 1,
defaultPageSize: 5,
},
makeStateHookFactory('persistence')
stateHookFactory
)
const [data, setData] = useState()

Expand Down

0 comments on commit ec5f6c0

Please sign in to comment.