-
Notifications
You must be signed in to change notification settings - Fork 2.1k
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
Deep comparison of parameters prop in Layer #6754
Conversation
In the functional programming model, one relies on a new object being minted when something changes, so shallow compare is enough. deepEqual has some perf impact. That said the diffing cost for params objects would typically be small, and this does remove a possible "gotcha" for non-functional programmers. Do we as a general rule want to support mutable properties across the api? Are there other props that need the same treatment. |
@ibgreen We do deep comparison in a few other cases, for example color values ( I believe the problem lies in the original design that A "proper" fix that aligns the /// BAD
new TileLayer({
data: ...,
getTileData: ...,
maxZoom: 14,
parameters: {},
getLineWidth: f => ...,
getFillColor: f => ...,
getLineColor: lineColor,
getPointRadius: 4,
renderSubLayers: props => new GeoJsonLayer(props)
}); /// GOOD
new TileLayer({
data: ...,
getTileData: ...,
maxZoom: 14,
renderSubLayers: props => new GeoJsonLayer(props, {
parameters: {},
getLineWidth: f => ...,
getFillColor: f => ...,
getLineColor: lineColor,
getPointRadius: 4
}),
updateTriggers: {
renderSubLayers: [lineColor]
}
}); Both approach work with the current release, but the second is much more performant in React with managed view states. We can update the documentation and examples to promote the latter, and deprecate the first use case in the next major release. |
True, there is a concern about false positives (newly minted object with same props), as well as false negatives (same object with mutated props) which I was thinking about. Yes perhaps it is be better to go all-in on deep comparisons. Could that allow us to not have to recommend such custom |
Would it make sense in that case to have the |
For #6750
Change List
equal
method forobject
propTypeparameters
prop marked for deep comparison inLayer