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
b37eee96
authored
2024-05-03 14:49:45 -0500
by
Adam Heath
Browse Files
Options
Browse Files
Tag
Download
Email Patches
Plain Diff
Copy defaultProps, displayName, and propTypes from the wrapped
component.
1 parent
10578956
Hide whitespace changes
Inline
Side-by-side
Showing
1 changed file
with
15 additions
and
9 deletions
src/react.jsx
src/react.jsx
View file @
b37eee9
...
...
@@ -4,14 +4,20 @@ import "use-sync-external-store/with-selector.js"
import
{
Provider
}
from
'react-redux'
import
{
getBrowserStore
}
from
'./client.mjs'
export
const
ReduxAstroProvider
=
(
Component
)
=>
(
props
)
=>
{
const
{
ASTRO_STORE
:
possibleStore
=
{},
...
rest
}
=
props
const
store
=
possibleStore
.
dispatch
?
possibleStore
:
getBrowserStore
()
export
const
ReduxAstroProvider
=
(
Component
)
=>
{
const
Wrapped
=
(
props
)
=>
{
const
{
ASTRO_STORE
:
possibleStore
=
{},
...
rest
}
=
props
const
store
=
possibleStore
.
dispatch
?
possibleStore
:
getBrowserStore
()
return
(
<
Provider
store=
{
store
}
><
Component
{
...
rest
}
/></
Provider
>
)
return
(
<
Provider
store=
{
store
}
><
Component
{
...
rest
}
/></
Provider
>
)
}
if
(
Component
.
defaultProps
)
Wrapped
.
defaultProps
=
Component
.
defaultProps
if
(
Component
.
propTypes
)
Wrapped
.
propTypes
=
Component
.
propTypes
if
(
Component
.
displayName
)
Wrapped
.
displayName
=
Component
.
displayName
return
Wrapped
}
...
...
Please
register
or
sign in
to post a comment