question-mark
Stuck on an issue?

Lightrun Answers was designed to reduce the constant googling that comes with debugging 3rd party libraries. It collects links to all the places you might be looking at while hunting down a tough bug.

And, if you’re still stuck at the end, we’re happy to hop on a call to see how we can help out.

Using .bind() in render

See original GitHub issue

Can this bind be moved outside of the render life-cycle (outside of render)?

https://foxhound87.github.io/mobx-react-form/docs/getting-started.html

<input {...form.$('username').bind()} />

If the form is re-rendering outside of mobx then this bind is going to unfortunately ensure react will consider the virtual DOM different and force it to update the real DOM even if the rest of the render did not change.

Issue Analytics

  • State:closed
  • Created 6 years ago
  • Comments:5 (3 by maintainers)

github_iconTop GitHub Comments

1reaction
jcalfeecommented, Aug 9, 2017

I’m not using the lib at the moment so I really can’t do a test case. I think your on the right track though if this is a safe change and something you want. I’m just giving a tip that I think will help your examples look good.

0reactions
foxhound87commented, Aug 10, 2017

Thanks for the suggestion, really appreciated. I’m going to close this issue, feel free to reopen if you need.

Read more comments on GitHub >

github_iconTop Results From Across the Web

bind(this) in ReactComponent.render() method - Stack Overflow
Oh, my original intention was to use bind in the render() method because the relevant code should group together.
Read more >
This is why we need to bind event handlers in Class ...
We need to bind these methods to the component instance using .bind() in our custom component's constructor. class Foo extends React.
Read more >
Passing Functions to Components - React
Using Function.prototype.bind in render creates a new function each time the component renders, which may have performance implications (see below).
Read more >
Properly using .bind() in React and understanding ... - Medium
“I'll just have to .bind() all of my component's methods to this , inside the constructor, and everything will be working fine again”....
Read more >
Best Alternative to Binding in Render - Dave Ceddia
If you're using React.createClass , the member functions in your component are automatically bound to the component instance. You can freely ...
Read more >

github_iconTop Related Medium Post

No results found

github_iconTop Related StackOverflow Question

No results found

github_iconTroubleshoot Live Code

Lightrun enables developers to add logs, metrics and snapshots to live code - no restarts or redeploys required.
Start Free

github_iconTop Related Reddit Thread

No results found

github_iconTop Related Hackernoon Post

No results found

github_iconTop Related Tweet

No results found

github_iconTop Related Dev.to Post

No results found

github_iconTop Related Hashnode Post

No results found