Skip to content

Commit

Permalink
ADD a warning for #5781
Browse files Browse the repository at this point in the history
  • Loading branch information
Tom Coleman committed Mar 2, 2019
1 parent a5352ab commit dc401dd
Showing 1 changed file with 8 additions and 0 deletions.
8 changes: 8 additions & 0 deletions lib/client-api/src/client_api.js
Original file line number Diff line number Diff line change
Expand Up @@ -134,6 +134,7 @@ export default class ClientApi {

const localDecorators = [];
let localParameters = {};
let hasAdded = false;
const api = {
kind,
};
Expand All @@ -148,6 +149,7 @@ export default class ClientApi {
});

api.add = (storyName, storyFn, parameters) => {
hasAdded = true;
const { _globalParameters, _globalDecorators } = this;
const id = toId(kind, storyName);

Expand Down Expand Up @@ -215,6 +217,12 @@ export default class ClientApi {
};

api.addDecorator = decorator => {
if (hasAdded) {
console.warn(`You have added a decorator to the kind '${kind}' after a story has already been added.
In Storybook 4 this applied the decorator only to subsequent stories. In Storybook 5+ it applies to all stories.
This is probably not what you intended. Read more here: https://github.com/storybooks/storybook/blob/master/MIGRATION.md`);
}

localDecorators.push(decorator);
return api;
};
Expand Down

0 comments on commit dc401dd

Please sign in to comment.