-
-
Notifications
You must be signed in to change notification settings - Fork 266
Fix hot reloading issues by removing the store from window #324
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
Fix hot reloading issues by removing the store from window #324
Conversation
|
|
||
| const initStore = <S extends Store>({makeStore, context, config}: InitStoreOptions<S>): S => { | ||
| const storeKey = getStoreKey(config); | ||
| let store: any; |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
this may not even be necessary, but it's probably a good idea to keep a global reference around in case getInitialProps is called client side. Far as I could test, client side getInitialProps used the existing store and state
| `createWrapper` also optionally accepts a config object as a second parameter: | ||
| - `storeKey` (optional, string) : the key used on `window` to persist the store on the client |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
this is no longer necessary
4c97e10 to
3063db7
Compare
packages/wrapper/src/index.tsx
Outdated
| ): GetServerSideProps<P> => async context => await getStaticProps(callback as any)(context); // just not to repeat myself | ||
|
|
||
| const withRedux = (Component: NextComponentType | App | any) => { | ||
| const withRedux: (Component: NextComponentType | App | any) => NextComponentType | App | any = Component => { |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
type inference couldn't properly figure it out.
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
nevermind, ended up reverting the change. Explicit typing is too much of a headache here, since it could be either Page or App, so a consumer would always need to specify which.
3063db7 to
60156d4
Compare
| const wrapper = createWrapper(makeStore, {storeKey: 'testStoreKey'}); | ||
| const Page = () => null; | ||
| Page.getInitialProps = wrapper.getInitialPageProps(store => () => null); | ||
| test('store is available when calling getInitialProps client-side and references the existing store on client', async () => { |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
I'm thinking this is sufficient to test the store is the same on client-side getInitialProps
e516388 to
63f8648
Compare
|
Great job. Thank you. I will review and merge shortly. |
63f8648 to
4618f1e
Compare
* Fix #280 * Fix #207 * Minor fixes * Updated API * Updated versions * Update README.md * Fixed demos & tests * Github Action * Make demo-dynamic private * Fix #326 * Fix hot reloading issues by removing the store from window (#324) Co-authored-by: Melanie Seltzer <[email protected]> Co-authored-by: Daniel Ferenc Balogh <[email protected]>
Fixes #317