storybook/docs/snippets/react/component-story-custom-args-complex.js.mdx
Helen 79911aa566
Adds missing character in prop
Adds a missing 'r'!
2021-01-08 12:25:59 -05:00

46 lines
995 B
Plaintext

```js
// YourComponent.stories.js
import React from 'react';
import { YourComponent } from './your-component'
// a function to apply some computations
const someFunction = (valuePropertyA, valuePropertyB) => {
// makes some computations and returns something
};
export default {
component: YourComponent,
title: 'A complex case with a function',
// creates specific argTypes with options
argTypes: {
propertyA: {
control: {
type: 'select',
options: [
'Item One',
'Item Two',
'Item Three'
],
},
},
propertyB: {
control: {
type: 'select',
options: [
'Another Item One',
'Another Item Two',
'Another Item Three'
],
},
},
},
};
const Template = ({ propertyA, propertyB, ...rest }) => {
const someFunctionResult = someFunction(propertyA, propertyB);
return <YourComponent someProperty={someFunctionResult} {...rest} />;
};
```