Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

setSteps is marked as an optional prop? #631

Open
CameronB9 opened this issue May 28, 2024 · 2 comments
Open

setSteps is marked as an optional prop? #631

CameronB9 opened this issue May 28, 2024 · 2 comments

Comments

@CameronB9
Copy link

I'm getting the below typescript error:

image

I have had a look at the index.d.ts file and it looks like it is marked as optional:

type ClickProps = {
    ...
    setSteps?: Dispatch<React.SetStateAction<StepType[]>>;
}

I have also had a quick look at the source code and it's not conditionally defined there. Am I missing something, should the prop be marked optional?

@elrumordelaluz
Copy link
Owner

Hi @CameronB9, thanks for open the Issue.

From which Component/prop are you trying to use ClickProps.setSetps?

@CameronB9
Copy link
Author

It's the useTour hook. Here's a small example:

import { useTour } from '@reactour/tour';

const { setSteps } = useTour();

const steps = mySteps.filter(filterFn);

// error here, object is possibly undefined
setSteps(steps)

I am setting different steps depending on which page the user is currently on.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

No branches or pull requests

2 participants