Skip to content

Commit

Permalink
Merge branch 'master' into terminal-logo
Browse files Browse the repository at this point in the history
  • Loading branch information
ndelangen authored Jul 22, 2017
2 parents 273d6f7 + 42c112c commit ffc9e90
Show file tree
Hide file tree
Showing 6 changed files with 27 additions and 6 deletions.
7 changes: 3 additions & 4 deletions addons/knobs/src/components/Panel.js
Original file line number Diff line number Diff line change
Expand Up @@ -93,11 +93,10 @@ export default class Panel extends React.Component {

queryParams[`knob-${name}`] = Types[knob.type].serialize(knob.value);
});
this.loadedFromUrl = true;
api.setQueryParams(queryParams);
this.setState({ knobs });
}

this.loadedFromUrl = true;
api.setQueryParams(queryParams);
this.setState({ knobs });
}

reset() {
Expand Down
2 changes: 1 addition & 1 deletion app/react-native/package.json
Original file line number Diff line number Diff line change
Expand Up @@ -74,6 +74,6 @@
},
"peerDependencies": {
"react": "*",
"react-native": "0.27.0 - 0.43.x"
"react-native": ">=0.27.0"
}
}
6 changes: 6 additions & 0 deletions app/react/src/client/preview/client_api.js
Original file line number Diff line number Diff line change
Expand Up @@ -8,6 +8,7 @@ export default class ClientApi {
this._storyStore = storyStore;
this._addons = {};
this._globalDecorators = [];
this._storiesAdded = false;
}

setAddon(addon) {
Expand All @@ -18,6 +19,9 @@ export default class ClientApi {
}

addDecorator(decorator) {
if (this._storiesAdded) {
throw new Error('Global decorators added after loading stories will not be applied');
}
this._globalDecorators.push(decorator);
}

Expand Down Expand Up @@ -51,6 +55,8 @@ export default class ClientApi {
});

api.add = (storyName, getStory) => {
this._storiesAdded = true;

if (typeof storyName !== 'string') {
throw new Error(`Invalid or missing storyName provided for a "${kind}" story.`);
}
Expand Down
10 changes: 10 additions & 0 deletions app/react/src/client/preview/client_api.test.js
Original file line number Diff line number Diff line change
Expand Up @@ -150,6 +150,16 @@ describe('preview.client_api', () => {
expect(storyStore.stories[0].fn()).toBe('bb-Hello');
});

it('should throw on adding global decorators after stories', () => {
const storyStore = new StoryStore();
const api = new ClientAPI({ storyStore });
const localApi = api.storiesOf('none');
localApi.add('storyName', () => 'Hello');
expect(() => {
api.addDecorator(fn => `bb-${fn()}`);
}).toThrow('Global decorators added after loading stories will not be applied');
});

it('should utilize both decorators at once', () => {
const storyStore = new StoryStore();
const api = new ClientAPI({ storyStore });
Expand Down
6 changes: 6 additions & 0 deletions docs/pages/basics/faq/index.md
Original file line number Diff line number Diff line change
Expand Up @@ -23,3 +23,9 @@ Next automatically defines `React` for all of your files via a babel plugin. You
### How do I setup Storybook to share Webpack configuration with Next.js?

You can generally reuse webpack rules fairly easily by placing them in a file that is `require()`-ed from both your `next.config.js` and your `.storybook/webpack.config.js` files. For example, [this gist](https://gist.github.com/metasean/cadd2becd60cc3b295bf49895a56f9b4) sets both next.js and storybook up with global stylesheets.

### Why is there no addons channel?

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)
2 changes: 1 addition & 1 deletion lib/ui/package.json
Original file line number Diff line number Diff line change
Expand Up @@ -31,7 +31,7 @@
"react-inspector": "^2.1.1",
"react-komposer": "^2.0.0",
"react-modal": "^1.7.7",
"react-split-pane": "^0.1.63",
"react-split-pane": "^0.1.65",
"redux": "^3.6.0"
},
"devDependencies": {
Expand Down

0 comments on commit ffc9e90

Please sign in to comment.