Skip to content
Toggle navigation
Toggle navigation
This project
Loading...
Sign in
brainfood
/
astro-redux
Go to a project
Toggle navigation
Toggle navigation pinning
Projects
Groups
Snippets
Help
Project
Activity
Repository
Pipelines
Graphs
Issues
0
Merge Requests
0
Wiki
Network
Create a new issue
Builds
Commits
Issue Boards
Files
Commits
Network
Compare
Branches
Tags
27cbbbf8
authored
2024-05-03 15:30:14 -0500
by
Adam Heath
Browse Files
Options
Browse Files
Tag
Download
Email Patches
Plain Diff
Add RefreshToken(astro+jsx)
1 parent
54053655
Hide whitespace changes
Inline
Side-by-side
Showing
3 changed files
with
32 additions
and
0 deletions
src/RefreshToken.astro
src/RefreshToken.jsx
src/astro.mjs
src/RefreshToken.astro
0 → 100644
View file @
27cbbbf
---
import ReduxIsland from './ReduxIsland.astro'
import RefreshToken from './RefreshToken.jsx'
---
<ReduxIsland>{props => <RefreshToken client:load {...props}/>}</ReduxIsland>
src/RefreshToken.jsx
0 → 100644
View file @
27cbbbf
import
React
from
'react'
import
{
ReduxAstroProvider
}
from
'astro-redux/react'
import
{
useGetTokenQuery
}
from
'astro-redux/slices'
const
RefreshToken
=
ReduxAstroProvider
((
props
)
=>
{
const
[
retry
,
setRetry
]
=
React
.
useState
(
props
.
retry
)
React
.
useEffect
(()
=>
{
if
(
retry
!==
props
.
retry
)
setRetry
(
props
.
retry
)
},
[
props
.
retry
])
const
getTokenQueryResult
=
useGetTokenQuery
(
undefined
,
{
pollingInterval
:
retry
})
const
{
data
:
{
expires_at
,
access_token
}
=
{}
}
=
getTokenQueryResult
React
.
useEffect
(()
=>
{
if
(
!
access_token
)
setRetry
(
0
)
},
[
access_token
])
return
null
})
RefreshToken
.
defaultProps
=
{
retry
:
60000
,
}
export
default
RefreshToken
src/astro.mjs
View file @
27cbbbf
...
...
@@ -39,3 +39,5 @@ export const createAstroApiWrappers = (apiWrappers) => Object.entries(apiWrapper
}, {})
export { default as AstroReduxProvider } from './Provider.astro'
export { default as RefreshToken } from './RefreshToken.astro'
export { default as RefreshTokenReact } from './RefreshToken.jsx'
...
...
Please
register
or
sign in
to post a comment