Skip to content

Commit

Permalink
rename: useStore -> useRootStore
Browse files Browse the repository at this point in the history
  • Loading branch information
mairisb committed Jan 22, 2024
1 parent 130d401 commit a3764a5
Show file tree
Hide file tree
Showing 7 changed files with 14 additions and 14 deletions.
6 changes: 3 additions & 3 deletions packages/client/src/app/navigation-bar/navigation-bar.tsx
Original file line number Diff line number Diff line change
@@ -1,10 +1,10 @@
import { observer } from 'mobx-react-lite';
import { Container, Nav, NavDropdown, Navbar } from 'react-bootstrap';
import { Link } from 'react-router-dom';
import { useStore } from '../../core/root.store';
import { useRootStore } from '../../core/root.store';

const UserDropdown = observer(() => {
const { authStore } = useStore();
const { authStore } = useRootStore();

return (
<NavDropdown
Expand All @@ -28,7 +28,7 @@ const UserDropdown = observer(() => {
});

export const NavigationBar: React.FC = observer(() => {
const { authStore } = useStore();
const { authStore } = useRootStore();

return (
<Navbar bg="primary" data-bs-theme="dark" className="bg-body-tertiary">
Expand Down
2 changes: 1 addition & 1 deletion packages/client/src/core/root.store.ts
Original file line number Diff line number Diff line change
Expand Up @@ -16,4 +16,4 @@ export class RootStore {
}

export const RootStoreContext = createContext<RootStore>(null as any);
export const useStore = () => useContext(RootStoreContext);
export const useRootStore = () => useContext(RootStoreContext);
4 changes: 2 additions & 2 deletions packages/client/src/features/auth/hooks/auth-redirect.hook.ts
Original file line number Diff line number Diff line change
@@ -1,10 +1,10 @@
import { useEffect } from 'react';
import { useNavigate } from 'react-router-dom';
import { useStore } from '../../../core/root.store';
import { useRootStore } from '../../../core/root.store';

export const useAuthRedirect = (path = '/') => {
const navigate = useNavigate();
const { authStore } = useStore();
const { authStore } = useRootStore();

useEffect(() => {
if (authStore.isAuthenticated) {
Expand Down
4 changes: 2 additions & 2 deletions packages/client/src/pages/home/home.page.tsx
Original file line number Diff line number Diff line change
@@ -1,9 +1,9 @@
import { observer } from 'mobx-react-lite';
import { useStore } from '../../core/root.store';
import { useRootStore } from '../../core/root.store';
import { Page } from '../page';

export const HomePage: React.FC = observer(() => {
const { authStore } = useStore();
const { authStore } = useRootStore();

return (
<Page title="Home">
Expand Down
4 changes: 2 additions & 2 deletions packages/client/src/pages/login/login.page.tsx
Original file line number Diff line number Diff line change
@@ -1,6 +1,6 @@
import { observer } from 'mobx-react-lite';
import { Link } from 'react-router-dom';
import { useStore } from '../../core/root.store';
import { useRootStore } from '../../core/root.store';
import {
LoginForm,
LoginFormData,
Expand All @@ -11,7 +11,7 @@ import { Page } from '../page';
export const LoginPage: React.FC = observer(() => {
useAuthRedirect();

const { authStore } = useStore();
const { authStore } = useRootStore();

const handleSubmit = (formData: LoginFormData) => {
authStore.login(formData);
Expand Down
4 changes: 2 additions & 2 deletions packages/client/src/pages/page.tsx
Original file line number Diff line number Diff line change
@@ -1,7 +1,7 @@
import { useEffect } from 'react';
import { useNavigate } from 'react-router-dom';
import { config } from '../core/config';
import { useStore } from '../core/root.store';
import { useRootStore } from '../core/root.store';
import { observer } from 'mobx-react-lite';

export interface PageProps extends React.PropsWithChildren {
Expand All @@ -11,7 +11,7 @@ export interface PageProps extends React.PropsWithChildren {

export const Page: React.FC<PageProps> = observer(
({ isAuthProtected = false, title, children }) => {
const { authStore } = useStore();
const { authStore } = useRootStore();

const navigate = useNavigate();

Expand Down
4 changes: 2 additions & 2 deletions packages/client/src/pages/register/register.page.tsx
Original file line number Diff line number Diff line change
@@ -1,5 +1,5 @@
import { observer } from 'mobx-react-lite';
import { useStore } from '../../core/root.store';
import { useRootStore } from '../../core/root.store';
import {
RegisterForm,
RegisterFormData,
Expand All @@ -10,7 +10,7 @@ import { Page } from '../page';
export const RegisterPage: React.FC = observer(() => {
useAuthRedirect();

const { authStore } = useStore();
const { authStore } = useRootStore();

const handleSubmit = (formData: RegisterFormData) => {
authStore.register(formData);
Expand Down

0 comments on commit a3764a5

Please sign in to comment.