Logo Questions Linux Laravel Mysql Ubuntu Git Menu
 

React adding css class without rerender

In my project I have table, each row has his own class depends on state. I also have sticked columns so when I do horizontal scroll then some columns are fixed.

My problem is that when some state is changing (eg. from none to rejected) i need to mark this row as rejected className and change background color.

Using setState is problematic because whole row is rerendered so my sticky columns are gone (I do calculations on every scroll event).

The question is: is there any other solution to change react className without rerendering my row? (besides jQuery)

like image 822
Rafal Lesniak Avatar asked Sep 15 '16 11:09

Rafal Lesniak


1 Answers

Change the state in your Row component so that the class is updated. Then, use PureComponent (https://github.com/facebook/react/pull/7195) on your child components so that they will not rerender unless their own props changed. Does that solve your problem?

like image 127
zackify Avatar answered Oct 04 '22 21:10

zackify