[WIP] Row as a React.PureComponent #404
Closed
Add this suggestion to a batch that can be applied as a single commit. This suggestion is invalid because no changes were made to the code. Suggestions cannot be applied while the pull request is closed. Suggestions cannot be applied while viewing a subset of changes. Only one suggestion per line can be applied in a batch. Add this suggestion to a batch that can be applied as a single commit. Applying suggestions on deleted lines is not supported. You must change the existing code in this line in order to create a valid suggestion. Outdated suggestions cannot be applied. This suggestion has been applied or marked resolved. Suggestions cannot be applied from pending reviews. Suggestions cannot be applied on multi-line comments. Suggestions cannot be applied while the pull request is queued to merge. Suggestion cannot be applied right now. Please check back later.
So this is a first attempt to make this table library more performant. Partially addresses #392.
This PR covers only the
Rowcomponent (inBody), because it is the most important and it covers only some cases. It handlesrowClassesandrowEventswell (at least in our case), which is our use-case.Current issues of this PR:
selectRowwell when it hasselectedthat changes. We probably need deep comparison there. Also, if someone changesselectRow.selected, it gets passed to every row, so that would need rework as well. Since this little thing is quite complex, it would probably be better to resolve this in another PR.emptyplaceholders for all things is a good pattern. We could also doemptyPlainObject = {};andemptyArray = [];and share that globally. Do we care?cellSelectionInfo. Not sure if merg-eable like this.resolveSelectRowPropsstatic for the purpose above. Also not sure if it makes sense mixed like this with the other methods.componentWillReceivePropsis probably not a good idea, because it is deprecated and will be removed in React 17. I couldn't figure out another easy approach though.getDerivedStateFromPropsis static unfortunately.ADDED: It needs the very sameThis should actually be responsibility of the caller I guess?datanot to re-render. So we probably need some sort of deep comparison and internal state for data rows too?This is mainly to kick-off the discussion about this. I think it would be awesome, if even a basic version of this concept would be merged, since preventing some parts of the table to re-render needlessly is a much more difficult task and every small step is a benefit (especially doing this for the
Rowcomponent).I appreciate ideas / comments / ...
Thank you.