Kitware / paraviewweb

Web framework for building interactive visualization relying on VTK or ParaView to produce visualization data
http://kitware.github.io/paraviewweb/
BSD 3-Clause "New" or "Revised" License
165 stars 51 forks source link

fix(VtkRenderer): Properly push props at initialization time #444

Closed jourdain closed 6 years ago

felixveysseyre commented 6 years ago

@jourdain It should work but the implementation is not optimal.

React method componentWillReceiveProps will always return the complete set of properties. For each property, you need to check if the new value is different than the current one:

componentWillReceiveProps(nextProps) {
    if (nextProps.myProp !== this.props.myProp)
    {
        //Do something
    }
}
jourdain commented 6 years ago

You really have hard time with code responsibility leakage. This is already managed in each component individually. Therefore, it is not needed to duplicate that check again and again in various layer of your application.

felixveysseyre commented 6 years ago

These check are really required here.

As I explained in my previous message, you will always receive a complete set of properties (containing both changed and unchanged props) in componentWillReceiceProps method. Therefore, with your implementation, you will send to the server several useless orders, as you will ask to update some parameters which already have the value you asked for.

jourdain commented 6 years ago

No they are not! And if they are, the issue is somewhere else...

Can you point me the code that send those useless information when they are the same? Because that would be their responsibility to handle that use case, not the application or this React component.

jourdain commented 6 years ago

BTW, I'm well aware that method get called each time any property change with all the properties.

jourdain commented 6 years ago

Better design here: https://github.com/Kitware/paraviewweb/pull/446

jourdain commented 6 years ago

I was taking the time to explain so you can learn and get better at your development/design. But I guess you could not grasp what I was talking about.