call React Hooks in global decorator for Storybook

Viewed 112

I want to call custom react hook for all stories, however, im not sure where to declare. The custom hooks I wanna call must be in context provider.

Are there any ways to declare context provider and custom hooks for all stories?

import React from 'react';
import { useCustomHooks } from './custom';
import { ThemeProvider } from 'styled-components';

export const decorators = [
  (Story) => (
    useCustomHooks() // I wanna call custom hooks here but not working because not in provider
    <ThemeProvider theme="default">
      <Story />
    </ThemeProvider>
  ),
];

0 Answers
Related