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

[TextField] with value via parents props latency between typings #1040

Closed
mstamos opened this issue Jul 5, 2015 · 10 comments
Closed

[TextField] with value via parents props latency between typings #1040

mstamos opened this issue Jul 5, 2015 · 10 comments
Labels
component: text field This is the name of the generic UI component, not the React module!

Comments

@mstamos
Copy link

mstamos commented Jul 5, 2015

When I use TextField with value from parents props there is a latency between typing a letter and displaying it on the screen. I see this issue on my project and at official page for TextField component (I talk about the third TextField from the first colunm).

@chrismcv
Copy link
Contributor

chrismcv commented Jul 8, 2015

I've seen this too. I think because the state object on the parent component is changing, this is causing every field to re-render.

In house, we're wrapping field, and have a pure-render-mixin applied - however we had to suppose valueLink, and some deepness in models - which the React.addons.PureRenderMixin doesn't.

@hai-cea - is something like this too opinionated to include in the core?

(Excuse the coffeescript)

_ = require 'lodash'

module.exports =
  shouldComponentUpdate: (nextProps, nextState) ->
    for key of nextProps
      if key is 'onChange'
        continue
      if key is 'valueLink'
        return true if nextProps.valueLink.value isnt @props.valueLink.value
      else if not _.eq(nextProps?[key], this.props?[key])
        return true
      else if not _.eq(nextState?[key], this.state?[key])
        return true
    return false

@hai-cea
Copy link
Member

hai-cea commented Jul 8, 2015

@chrismcv I think we need to address shouldComponentUpdate for most if not all of our components. What about children though?

@chrismcv
Copy link
Contributor

chrismcv commented Jul 8, 2015

_.eq is deep - which should deal with children - i'm sure it's not mega efficient though... but at the same time has yielded a performance improvement for me

@chrismcv chrismcv mentioned this issue Jul 9, 2015
@mstamos
Copy link
Author

mstamos commented Jul 13, 2015

Is there any way to prevent the others component to re-render when I typing into TextField? One more question this will be fixed in a new material-ui version?

@hai-cea hai-cea changed the title TextField with value via parents props latency between typings [TextField] with value via parents props latency between typings Jul 16, 2015
@CoDEmanX
Copy link

Typing in textfields is indeed extremely slow, Firefox and Chrome. If you type really fast, it may even lock up for 2-3 seconds.

//edit: tested on demo page Text Fields.

@Kagami
Copy link

Kagami commented Jul 31, 2015

Encountered the same problem. I'm currently using onBlur, getValue and setValue as a workaround and handle the updates only after input lost the focus.

@juhaelee
Copy link

juhaelee commented Aug 5, 2015

@hai-cea the pull request I just opened should fix the textfield lag in the demo page significantly. Belle had a similar issue in their docs

@shaurya947
Copy link
Contributor

@mstamos @CoDEmanX @Kagami can you test again? I don't see this issue today on the docs website.. We've since implemented the PureRenderMixin so I think it has taken care of the issue

@CoDEmanX
Copy link

Seems to work very smooth now, only tested chrome but I think that fixed it. Great job!

@zannager zannager added the component: text field This is the name of the generic UI component, not the React module! label Dec 22, 2022
@archie-bryann
Copy link

Encountered the same problem. I'm currently using onBlur, getValue and setValue as a workaround and handle the updates only after input lost the focus.

how can i do this, im experiencing the same issue?

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
component: text field This is the name of the generic UI component, not the React module!
Projects
None yet
Development

No branches or pull requests

10 participants