Skip to content

Commit

Permalink
Refactor StoreContext to RootStoreContext
Browse files Browse the repository at this point in the history
  • Loading branch information
mairisb committed Jan 22, 2024
1 parent 56071ee commit b329c90
Show file tree
Hide file tree
Showing 3 changed files with 8 additions and 8 deletions.
4 changes: 2 additions & 2 deletions packages/client/src/core/root.store.ts
Original file line number Diff line number Diff line change
Expand Up @@ -15,5 +15,5 @@ export class RootStore {
}
}

export const StoreContext = createContext(new RootStore());
export const useStore = () => useContext(StoreContext);
export const RootStoreContext = createContext<RootStore>(null as any);
export const useStore = () => useContext(RootStoreContext);
6 changes: 3 additions & 3 deletions packages/client/src/index.tsx
Original file line number Diff line number Diff line change
Expand Up @@ -2,7 +2,7 @@ import { StrictMode } from 'react';
import * as ReactDOM from 'react-dom/client';
import { BrowserRouter } from 'react-router-dom';
import { App } from './app/app';
import { RootStore, StoreContext } from './core/root.store';
import { RootStore, RootStoreContext } from './core/root.store';

const root = ReactDOM.createRoot(
document.getElementById('root') as HTMLElement,
Expand All @@ -13,9 +13,9 @@ const rootStore = new RootStore();
root.render(
<StrictMode>
<BrowserRouter>
<StoreContext.Provider value={rootStore}>
<RootStoreContext.Provider value={rootStore}>
<App />
</StoreContext.Provider>
</RootStoreContext.Provider>
</BrowserRouter>
</StrictMode>,
);
6 changes: 3 additions & 3 deletions packages/client/src/utils/test.utils.tsx
Original file line number Diff line number Diff line change
Expand Up @@ -2,7 +2,7 @@ import type { RenderOptions } from '@testing-library/react';
import { render } from '@testing-library/react';
import React, { PropsWithChildren } from 'react';
import { MemoryRouter } from 'react-router-dom';
import { RootStore, StoreContext } from '../core/root.store';
import { RootStore, RootStoreContext } from '../core/root.store';

interface ExtendedRenderOptions extends RenderOptions {
rootStore?: RootStore;
Expand All @@ -14,9 +14,9 @@ export const renderWithProviders = (
) => {
const Wrapper = ({ children }: PropsWithChildren<{}>): JSX.Element => {
return (
<StoreContext.Provider value={rootStore}>
<RootStoreContext.Provider value={rootStore}>
<MemoryRouter>{children}</MemoryRouter>
</StoreContext.Provider>
</RootStoreContext.Provider>
);
};

Expand Down

0 comments on commit b329c90

Please sign in to comment.