Copy defaultProps, displayName, and propTypes from the wrapped
component.
Showing
1 changed file
with
15 additions
and
9 deletions
... | @@ -4,14 +4,20 @@ import "use-sync-external-store/with-selector.js" | ... | @@ -4,14 +4,20 @@ import "use-sync-external-store/with-selector.js" |
4 | import { Provider } from 'react-redux' | 4 | import { Provider } from 'react-redux' |
5 | import { getBrowserStore } from './client.mjs' | 5 | import { getBrowserStore } from './client.mjs' |
6 | 6 | ||
7 | export const ReduxAstroProvider = (Component) => (props) => { | 7 | export const ReduxAstroProvider = (Component) => { |
8 | const { | 8 | const Wrapped = (props) => { |
9 | ASTRO_STORE: possibleStore = {}, | 9 | const { |
10 | ...rest | 10 | ASTRO_STORE: possibleStore = {}, |
11 | } = props | 11 | ...rest |
12 | const store = possibleStore.dispatch ? possibleStore : getBrowserStore() | 12 | } = props |
13 | const store = possibleStore.dispatch ? possibleStore : getBrowserStore() | ||
13 | 14 | ||
14 | return ( | 15 | return ( |
15 | <Provider store={store}><Component {...rest}/></Provider> | 16 | <Provider store={store}><Component {...rest}/></Provider> |
16 | ) | 17 | ) |
18 | } | ||
19 | if (Component.defaultProps) Wrapped.defaultProps = Component.defaultProps | ||
20 | if (Component.propTypes) Wrapped.propTypes = Component.propTypes | ||
21 | if (Component.displayName) Wrapped.displayName = Component.displayName | ||
22 | return Wrapped | ||
17 | } | 23 | } | ... | ... |
-
Please register or sign in to post a comment