Skip to content

Commit

Permalink
chore(elements): Remove unused contexts
Browse files Browse the repository at this point in the history
  • Loading branch information
tmilewski committed Oct 4, 2024
1 parent 4641be0 commit 300168c
Show file tree
Hide file tree
Showing 3 changed files with 4 additions and 24 deletions.
Original file line number Diff line number Diff line change
@@ -1,7 +1,6 @@
import { Slot } from '@radix-ui/react-slot';
import * as React from 'react';

import { createContextForDomValidation } from '~/react/utils/create-context-for-dom-validation';
import { isValidComponentType } from '~/react/utils/is-valid-component-type';

import {
Expand All @@ -26,21 +25,13 @@ export type SignInSessionListItemProps = Omit<React.HTMLAttributes<HTMLLIElement
children: ({ session }: { session: SignInActiveSessionListItem }) => React.ReactNode;
};

// ---------------------------------- CONTEXT -----------------------------------

export const SignInChooseSessionCtx = createContextForDomValidation('SignInChooseSessionCtx');

// --------------------------------- COMPONENTS ---------------------------------

export function SignInChooseSession({ asChild, children, ...props }: SignInChooseSessionProps) {
const activeState = useSignInChooseSessionIsActive();
const Comp = asChild ? Slot : 'div';

return activeState ? (
<SignInChooseSessionCtx.Provider>
<Comp {...props}>{children}</Comp>
</SignInChooseSessionCtx.Provider>
) : null;
return activeState ? <Comp {...props}>{children}</Comp> : null;
}

export function SignInSessionList({ asChild, children, includeCurrentSession, ...props }: SignInSessionListProps) {
Expand Down
15 changes: 2 additions & 13 deletions packages/elements/src/react/sign-in/choose-strategy.tsx
Original file line number Diff line number Diff line change
Expand Up @@ -7,7 +7,6 @@ import { SignInCurrentStrategy, SignInFactors } from '~/internals/machines/sign-

import { useActiveTags } from '../hooks';
import { ActiveTagsMode } from '../hooks/use-active-tags.hook';
import { createContextForDomValidation } from '../utils/create-context-for-dom-validation';
import { SignInRouterCtx, SignInStrategyContext } from './context';

// --------------------------------- HELPERS ---------------------------------
Expand Down Expand Up @@ -41,18 +40,12 @@ export type SignInForgotPasswordProps = React.HTMLAttributes<HTMLDivElement> & {
asChild?: boolean;
};

export const SignInChooseStrategyCtx = createContextForDomValidation('SignInChooseStrategyCtx');

export function SignInChooseStrategy({ asChild, children, ...props }: SignInChooseStrategyProps) {
const routerRef = SignInRouterCtx.useActorRef();
const activeState = useActiveTags(routerRef, 'step:choose-strategy');
const Comp = asChild ? Slot : 'div';

return activeState ? (
<SignInChooseStrategyCtx.Provider>
<Comp {...props}>{children}</Comp>
</SignInChooseStrategyCtx.Provider>
) : null;
return activeState ? <Comp {...props}>{children}</Comp> : null;
}

export function SignInForgotPassword({ asChild, children, ...props }: SignInForgotPasswordProps) {
Expand All @@ -64,11 +57,7 @@ export function SignInForgotPassword({ asChild, children, ...props }: SignInForg
);
const Comp = asChild ? Slot : 'div';

return activeState ? (
<SignInChooseStrategyCtx.Provider>
<Comp {...props}>{children}</Comp>
</SignInChooseStrategyCtx.Provider>
) : null;
return activeState ? <Comp {...props}>{children}</Comp> : null;
}

const SUPPORTED_STRATEGY_NAME = 'SignInSupportedStrategy';
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -19,7 +19,7 @@ export function createContextForDomValidation(displayName: string) {

Provider.displayName = displayName;

function useContext(allowMissingContext: boolean = false) {
function useContext(allowMissingContext = false) {
const context = React.useContext(ReactContext);

if (!allowMissingContext && !context) {
Expand Down

0 comments on commit 300168c

Please sign in to comment.