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

Custom components unmount and mount with every state update #42

Closed
mknabe opened this issue Jan 25, 2017 · 9 comments
Closed

Custom components unmount and mount with every state update #42

mknabe opened this issue Jan 25, 2017 · 9 comments

Comments

@mknabe
Copy link

mknabe commented Jan 25, 2017

I have two use cases I need to cover and I was wondering if there are any examples of these already before I dive into figuring it out on my own

  1. An editable table where the data in one row can be edited at a time and saving updates the table
  2. A table where each row has a checkbox to select the row then a button to submit the selected rows

Thanks!

@tannerlinsley
Copy link
Collaborator

tannerlinsley commented Jan 25, 2017 via email

@mknabe
Copy link
Author

mknabe commented Jan 25, 2017

Will do

@mknabe
Copy link
Author

mknabe commented Jan 30, 2017

I started implementing my first use case and it was easy enough... but it looks like if you do a custom column render, it will mount/unmount that component on every update which can cause a major slowdown. I'm not sure how to fix this but I plan on looking into it.

2017-01-30 14 08 19 screenshot

Edit: this isn't as much of a problem in production mode (with 25 rows)

@mi-lee
Copy link

mi-lee commented Feb 14, 2017

@mknabe, do you mean that it re-rendered the entire table (rather than the cell or row)? I'm also looking for a table with good editing capabilities. Did you end up making a PR?

@mknabe
Copy link
Author

mknabe commented Feb 14, 2017

@mi-lee I mean that if you have a custom render for a column like below. MyComponent will mount/unmount on every state change instead of just re-rendering. It can be a pretty big performance hit depending on what MyComponent is doing.

We are using redux-form and the performance hit was substantial so we had to switch to a different data table library :(

render: (props) => {
  return (
    <span className='number'>
      {props.value}
      <MyComponent />
    </span>
  );
}

@tannerlinsley
Copy link
Collaborator

@mknabe, this may have been due to some lack of internal key-ing. Have you tried the latest version? This is definitely not the type of functionality I want to keep around, so any help in making it work would be fantastic.

@tannerlinsley tannerlinsley changed the title Examples with forms? Custom components unmount and mount with every state update Feb 14, 2017
@tannerlinsley tannerlinsley reopened this Feb 14, 2017
@mknabe
Copy link
Author

mknabe commented Feb 14, 2017

@tannerlinsley looks fixed! 🥇

@tannerlinsley
Copy link
Collaborator

Awesome! Glad to hear :) You can also use standard (non-react) functions as custom renderers so long as they return a primitive that react can render (string, number, boolean, etc) :) Cheers!

@mi-lee
Copy link

mi-lee commented Feb 15, 2017

cool, thanks for getting back to me @mknabe!

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

3 participants