Solution header icon

Storybook error: Cannot destructure property ‘basename’ of ‘React2.useContext(…)’

You need to add code mentioned in bold to your Storybook component file.
Generally this error raises when you use react-router-dom context provider components like Link etc.
// Other code
export default {
title:”Components/TITLE”,
component:COMPONENT-NAME,
decorators: [
(Story: any) => (
<MemoryRouterinitialEntries={[“/”]}>
{/* Add any other context providers here */}
<Story/>
</MemoryRouter>
),
],
tags: [“autodocs”],
};
// Rest of the code

Difficulty

Normal

Related to

ReactJS, Storybook

logo of theitoons

Need professional assistance?

Get a response in less than 24 hours

Let's talk

Get a quote in less than 24 hours