Download wp-calypso/client/landing/stepper/hooks/use-first-step.ts from Devendra174/react-code-dataset: direct link, hf CLI and curl.
- Browser
- Download file 696 Bytes
-
https://huggingface.co/datasets/Devendra174/react-code-dataset/resolve/main/wp-calypso/client/landing/stepper/hooks/use-first-step.ts
- Command line
-
hf download hf://datasets/Devendra174/react-code-dataset/wp-calypso/client/landing/stepper/hooks/use-first-step.ts
-
curl -L -o use-first-step.ts https://huggingface.co/datasets/Devendra174/react-code-dataset/resolve/main/wp-calypso/client/landing/stepper/hooks/use-first-step.ts
696 Bytes
| import { useSelector } from 'calypso/state'; | |
| import { isUserLoggedIn } from 'calypso/state/current-user/selectors'; | |
| import type { StepperStep } from '../declarative-flow/internals/types'; | |
| /** | |
| * Returns the slug of the first step that should be rendered when the flow is visited without a specified step, while considering the logged in state of the user. | |
| * @param stepPaths the slugs of all the steps in the flow. | |
| * @returns the slug of the appropriate step. | |
| */ | |
| export const useFirstStep = ( stepPaths: StepperStep[ 'slug' ][] ) => { | |
| const isLoggedIn = useSelector( isUserLoggedIn ); | |
| if ( stepPaths[ 0 ] === 'user' && isLoggedIn ) { | |
| return stepPaths[ 1 ]; | |
| } | |
| return stepPaths[ 0 ]; | |
| }; | |