Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Bind "this" on API class methods #83

Open
nowlena opened this issue Apr 15, 2018 · 0 comments
Open

Bind "this" on API class methods #83

nowlena opened this issue Apr 15, 2018 · 0 comments

Comments

@nowlena
Copy link

nowlena commented Apr 15, 2018

I'm having an issue using the stencil-utils/src/api/product.js aka utils.api.product.getById method because of the "this" keyword.

Please bind(this) on all class methods to keep scope in order.

/**
 * FOR EXAMPLE 
 * after this line: https://github.com/bigcommerce/stencil-utils/blob/master/src/api/product.js#L13
 * add the following code
 */
this.getById = this.getById.bind(this);

This will prevent any issues with this referring to some outside Class

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

No branches or pull requests

1 participant