Skip to content

Commit

Permalink
feat: allow custom react-element-to-jsx-string options
Browse files Browse the repository at this point in the history
  • Loading branch information
rbardini authored Apr 10, 2020
1 parent cac88a5 commit ec6df5c
Show file tree
Hide file tree
Showing 2 changed files with 9 additions and 5 deletions.
11 changes: 7 additions & 4 deletions README.md
Original file line number Diff line number Diff line change
Expand Up @@ -40,10 +40,11 @@ See [`example`](example) for a minimal working setup.

The addon can be configured globally and per story with the `playroom` parameter. The following options are available:

| Option | Description | Default |
|:-----------|:-------------------------------------|:------------------------|
| `url` | the Playroom URL | `http://localhost:9000` |
| `disabled` | whether to disable the addon | `false` |
| Option | Description | Default |
|:---------------------------------|:-----------------------------------------|:------------------------|
| `url` | the Playroom URL | `http://localhost:9000` |
| `disabled` | whether to disable the addon | `false` |
| `reactElementToJSXStringOptions` | [react-element-to-jsx-string options][1] | `{ sortProps: false }` |

### Global configuration

Expand Down Expand Up @@ -82,3 +83,5 @@ myStory.story = {
},
};
```

[1]: https://github.com/algolia/react-element-to-jsx-string#reactelementtojsxstringreactelement-options
3 changes: 2 additions & 1 deletion src/index.tsx
Original file line number Diff line number Diff line change
Expand Up @@ -21,11 +21,12 @@ const Story: FC<Props> = ({
parameters: {
url = 'http://localhost:9000',
disabled = false,
reactElementToJSXStringOptions = { sortProps: false },
} = {},
},
}) => {
const story = getStory(context);
const jsxString = reactElementToJSXString(story);
const jsxString = reactElementToJSXString(story, reactElementToJSXStringOptions);
const channel = addons.getChannel();
const codeUrl = url && `${url}#?code=${base64Url.encode(jsxString)}`;

Expand Down

0 comments on commit ec6df5c

Please sign in to comment.