diff --git a/lib/client-api/src/client_api.js b/lib/client-api/src/client_api.js index b9b7925fff8d..2c5991394e00 100644 --- a/lib/client-api/src/client_api.js +++ b/lib/client-api/src/client_api.js @@ -134,6 +134,7 @@ export default class ClientApi { const localDecorators = []; let localParameters = {}; + let hasAdded = false; const api = { kind, }; @@ -148,6 +149,7 @@ export default class ClientApi { }); api.add = (storyName, storyFn, parameters) => { + hasAdded = true; const { _globalParameters, _globalDecorators } = this; const id = toId(kind, storyName); @@ -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; };