elrumordelaluz / reactour

Tourist Guide into your React Components
https://react.tours
MIT License
3.83k stars 344 forks source link

setSteps is marked as an optional prop? #631

Open CameronB9 opened 4 months ago

CameronB9 commented 4 months ago

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 commented 3 months ago

Hi @CameronB9, thanks for open the Issue.

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

CameronB9 commented 3 months ago

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.