EastsideCo / polaris-vue

Allows you to use Shopify Polaris components in Vue 2.
https://www.npmjs.com/package/@eastsideco/polaris-vue
113 stars 27 forks source link

onAction method seems to be getting called on load... infinitely. #5

Closed patrickbolle closed 6 years ago

patrickbolle commented 6 years ago

Really odd. For example I've got a Polaris section that looks like -

<polaris-page-actions 
            :primary-action="{content: 'Save', onAction: saveThing()}"
            :secondary-actions="[
                {content: 'Cancel'},
            ]">
        </polaris-page-actions>

As soon as the component is loaded, saveThing() gets called. And sometimes it seems to do this infinitely, killing the page and causing my browser to crash.

I don't think this could be something purely on my side - but maybe it is.

Any ideas here?

Thanks!

KatherinePrice commented 6 years ago

Sorry that we missed this - I'm sure you've already worked this out, but I'll answer in case anyone finds this.

The issue is that you're calling the method in the template, so it's being called every time the page loads. You want to use onAction: saveThing or onAction: () => saveThing().