Skip to content

Commit

Permalink
Merge pull request #1559 from storybooks/faq-component-state
Browse files Browse the repository at this point in the history
Add state-setting FAQ
  • Loading branch information
shilman authored Jul 31, 2017
2 parents 22fad69 + 6395881 commit e3bcd4d
Show file tree
Hide file tree
Showing 2 changed files with 28 additions and 9 deletions.
6 changes: 0 additions & 6 deletions CHANGELOG.md
Original file line number Diff line number Diff line change
Expand Up @@ -15,18 +15,12 @@ Plus many more features, documentation improvements, and bugfixes below!
- Vue support [#1267](https://github.com/storybooks/storybook/pull/1267)
- Add support for vue in addon-notes [#1278](https://github.com/storybooks/storybook/pull/1278)
- CLI support for Vue [#1287](https://github.com/storybooks/storybook/pull/1287)


- Story Hierarchy [#1329](https://github.com/storybooks/storybook/pull/1329)
- Story Hierarchy UI improvements [#1387](https://github.com/storybooks/storybook/pull/1387) [#1356](https://github.com/storybooks/storybook/pull/1356)
- Story Hierarchy - keyboard accessibility [#1427](https://github.com/storybooks/storybook/pull/1427)


- React Native - On Device UI [#1413](https://github.com/storybooks/storybook/pull/1413)
- Show first story on RN OnDeviceUI startup [#1510](https://github.com/storybooks/storybook/pull/1510)
- Added collapsible RN OnDeviceUI navigation [#1544](https://github.com/storybooks/storybook/pull/1544)


- Add warning when module is missing in storiesOf [#1525](https://github.com/storybooks/storybook/pull/1525)
- Provide styling hook for Addon Info story body [#1308](https://github.com/storybooks/storybook/pull/1308)
- Implement filtering on story-level [#1432](https://github.com/storybooks/storybook/pull/1432)
Expand Down
31 changes: 28 additions & 3 deletions docs/pages/basics/faq/index.md
Original file line number Diff line number Diff line change
@@ -1,7 +1,8 @@
---
* * *

id: 'faq'
title: 'Frequently Asked Questions'
---

## title: 'Frequently Asked Questions'

Here are some answers to frequently asked questions. If you have a question, you can ask it by opening an issue on the [Storybook Repository](https://github.com/storybooks/storybook/).

Expand Down Expand Up @@ -29,3 +30,27 @@ You can generally reuse webpack rules fairly easily by placing them in a file th
A common error is that an addon tries to access the "channel", but the channel is not set. This can happen in a few different cases:
1. In storybook/addon development, it can be an NPM version problem. If there are two versions of the addons NPM package, it will cause problems. In this case, make sure there is only a single version of `@storybook/addons` being used by your project.
2. In React Native, it's a special case that's documented in [#1192](https://github.com/storybooks/storybook/issues/1192)

### Can I modify React component state in stories?

Not directly. If you control the component source, you can do something like this:

```js
import React, { Component} from 'react';
import { storiesOf } from '@storybook/react';

class MyComponent extends Component {
constructor(props) {
super(props)
this.setState({
someVar: 'defaultValue',
...props.initialState
})
}
// ...
}

storiesOf('MyComponent', module)
.add('default', () => <MyComponent />)
.add('other', () => <MyComponent initialState={{ someVar: 'otherVal' }});
```

0 comments on commit e3bcd4d

Please sign in to comment.