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

Why have to bind this in router function? #342

Open
krave1986 opened this issue Oct 8, 2016 · 0 comments
Open

Why have to bind this in router function? #342

krave1986 opened this issue Oct 8, 2016 · 0 comments

Comments

@krave1986
Copy link

I am researching some example code about React based on director.js.
The example code shows that I have to bind thisArg to make sure the app could work well.
Could you please tell me why I have to bind this in router function?
Here is the snippet of the code.

        componentDidMount: function () {
            var setState = this.setState;
            var router = Router({
                '/': setState.bind(this, {nowShowing: app.ALL_TODOS}),
                '/active': setState.bind(this, {nowShowing: app.ACTIVE_TODOS}),
                '/completed': setState.bind(this, {nowShowing: app.COMPLETED_TODOS})
            });
            router.init('/');
        },
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