I am trying to deal with a problem where I am using react-slick. I mapped a JSON file for images and it gives me the error "Object is possibly 'null'.ts (2531)". I have to keep strict typing so I just can't get rid of it. Here is the part of the code that causing the problem:
const [slider, setSliderRef] = useState(null);
... // Some other coding
const settings = {
... // Some settings
afterChange: (i: React.SetStateAction<number>) => setSliderIndex(i),
}
... // Some more coding
{images.map((image: string | undefined, index: any) => (
<Box>
<img src={image} alt={index} className={className} onClick={() => slider.slickGoTo(index)} />
</Box>
))}
for the word slider here it says: "Object is possibly 'null'.ts (2531)" and of course it makes trouble on Jenkins side.
I tried some ways but no luck. Any idea?
Best