Decorators are functions used to wrap your stories in arbitrary markup (like Providers, Themes, or Layout wrappers). This is useful when your components expect specific context or styling environments.
Decorators can be applied at the global, component, or story level. In React Native, a decorator is a function that receives the Story component and returns a React element.
Note: When using a functional component as a decorator, you must render the story using <Story /> or call it as a function Story() to enable rendering.
import type { Meta, StoryObj } from '@storybook/react-native';
import { View } from 'react-native';
import { Button } from './Button';
const meta: Meta<typeof Button> = {
component: Button,
decorators: [
(Story) => (
<View style={{ padding: 16 }}>
<Story />
</View>
),
],
};
export default meta;