Skip to content

Commit

Permalink
provider -> context
Browse files Browse the repository at this point in the history
  • Loading branch information
nstepien committed Dec 22, 2024
1 parent 142d12b commit e6bc742
Show file tree
Hide file tree
Showing 2 changed files with 4 additions and 6 deletions.
4 changes: 1 addition & 3 deletions website/directionContext.ts
Original file line number Diff line number Diff line change
Expand Up @@ -2,9 +2,7 @@ import { createContext, useContext } from 'react';

import type { Direction } from '../src/types';

const DirectionContext = createContext<Direction>('ltr');

export const DirectionContextProvider = DirectionContext.Provider;
export const DirectionContext = createContext<Direction>('ltr');

export function useDirection(): Direction {
return useContext(DirectionContext);
Expand Down
6 changes: 3 additions & 3 deletions website/routes/__root.tsx
Original file line number Diff line number Diff line change
Expand Up @@ -3,7 +3,7 @@ import { createRootRoute, Outlet } from '@tanstack/react-router';
import { css } from '@linaria/core';

import type { Direction } from '../../src/types';
import { DirectionContextProvider } from '../directionContext';
import { DirectionContext } from '../directionContext';
import Nav from '../Nav';

export const Route = createRootRoute({
Expand All @@ -23,11 +23,11 @@ function Root() {
const [direction, setDirection] = useState<Direction>('ltr');

return (
<DirectionContextProvider value={direction}>
<DirectionContext value={direction}>
<Nav direction={direction} onDirectionChange={setDirection} />
<main dir={direction} className={mainClassname}>
<Outlet />
</main>
</DirectionContextProvider>
</DirectionContext>
);
}

0 comments on commit e6bc742

Please sign in to comment.