diff --git a/addons/actions/src/preview.js b/addons/actions/src/preview.js index fa722f3effe6..f4ed7a3e8b3d 100644 --- a/addons/actions/src/preview.js +++ b/addons/actions/src/preview.js @@ -24,16 +24,9 @@ export function action(name) { }); }; - // some day when {[name]: function() {}} syntax is not transpiled by babel - // we can get rid of this eval as by ES2015 spec the above function gets the - // name `name`, but babel transpiles to Object.defineProperty which doesn't do - // the same. - // - // Ref: https://bocoup.com/weblog/whats-in-a-function-name const fnName = name && typeof name === 'string' ? name.replace(/\W+/g, '_') : 'action'; - // eslint-disable-next-line no-eval - const named = eval(`(function ${fnName}() { return handler.apply(this, arguments) })`); - return named; + Object.defineProperty(handler, 'name', { value: fnName }); + return handler; } export function decorateAction(decorators) { diff --git a/examples/cra-kitchen-sink/src/__snapshots__/storyshots.test.js.snap b/examples/cra-kitchen-sink/src/__snapshots__/storyshots.test.js.snap index 3ad0629b9cbc..4b9d5dd48368 100644 --- a/examples/cra-kitchen-sink/src/__snapshots__/storyshots.test.js.snap +++ b/examples/cra-kitchen-sink/src/__snapshots__/storyshots.test.js.snap @@ -5563,6 +5563,15 @@ exports[`Storyshots Button addons composition 1`] = ` `; +exports[`Storyshots Button delete 1`] = ` + +`; + exports[`Storyshots Button with new info 1`] = `
)) + .add('delete', () => ( + + )) .add('with notes', () => ( // deprecated usage