Comments (9)
I am not very sure that this is a good idea, propsDiff
is mostly a debugging aid.
This is an artificial edge case. Normally, you should have used useCallback
on the map to prevent excessive refreshing. Maybe there are some optimizations possible, but it would be very bug prone and I don't think it will help a lot for any real-world use case. Also, you are not supposed to nest layers.
from rlayers.
Just imagine, in your case, what would happen if you had another nested level inside - for example with a feature - and its property did change depending on the map property. You would have blocked the propagation down the chain.
from rlayers.
Thanks for your time.
Considering this case
const App = () => {
cont [count, setCount] = React.useState(0);
return <RMap onChange={() => setCount(s => s + 1)}>
<RLayerTile>
<RLayerTileWMS url="https://example.com/wms" />
</RLayerTile />
</RMap>
}
After going throught some source code, i know that
RLayerTileWMS
extends RLayerBase
which eventually has base class PureComponent
. When state
in wrapper compoent(App) changes, RlayerTileWMS
should not be renderred because all i'ts props (only url in this case) are not changing. But the componentDidUpdate
did called. It makes me confusing... (Maybe the context is changing?)
from rlayers.
The context probably changes, but you are not supposed to be nesting layers at all. I don't want to optimize this case, as it will be very error-prone and it is an artificial edge case that forces an update of RMap
component. This should have been a constant function obtained by useCallback
- otherwise it will surely kill performance.
from rlayers.
Sorry for my copy&past mistake, in my minimum case, RLayerTileWMS
is not nested.
const App = () => {
cont [count, setCount] = React.useState(0);
return <RMap onChange={() => setCount(s => s + 1)}>
<RLayerTileWMS url="https://example.com/wms" />
</RMap>
}
from rlayers.
Ok, now it is correct, but it is still an artificial case.
from rlayers.
If you submit a PR that does not touch the base classes, but only RLayerTileWMS
, I will consider it. Do not use propsDiff
, it is a debugging aid.
from rlayers.
I found this is a common render issue that in RLayerBase
there is RContext
declared, further in RMap
which set the value of Context.Provider
.
In this way, React.PureComponent
was not acting as expected...
let me make a stackblitz
example then...
from rlayers.
Yes, rerendering a layer would replace the context object. If your problem is only with the RLayerTileWMS
, I prefer that you modify only this component. Currently, it will recreate the source, because the settings cannot be changed. This can probably be memoized.
Directly memoizing the context object could save rerenders, but it is a dangerous change that would have to be very thoroughly tested.
from rlayers.
Related Issues (20)
- is it possible to do layer pixel manipulation? HOT 1
- Using non-default projection with OSM and Next.js HOT 3
- RLayerWMTS fetches the wmts file twice HOT 4
- Popup fΓΆr vector tile layers HOT 1
- RStadiaLayer is not being exported HOT 2
- Is it possible to load tiles using the setTileLoadFunction ? HOT 2
- Unable to use `RPopup` with `RLayerCluster` HOT 10
- Snap doesn't work when use Rmodify HOT 4
- Can't set default rotation in the RView HOT 1
- map is undefined HOT 2
- Improvements for RLayerTileWMSProps HOT 1
- onDrawStart and onDrawEnd not working for RModify interaction HOT 4
- Calling an event only once HOT 3
- Setting tabindex HOT 2
- improve tile layer props HOT 1
- Google Maps Integration HOT 1
- Event Propagation in onPointerDrag HOT 3
- RDragZoom does not extend RDragBox and onChange appears not to work
- RLayerCluster url loading with react suspense
Recommend Projects
-
React
A declarative, efficient, and flexible JavaScript library for building user interfaces.
-
Vue.js
π Vue.js is a progressive, incrementally-adoptable JavaScript framework for building UI on the web.
-
Typescript
TypeScript is a superset of JavaScript that compiles to clean JavaScript output.
-
TensorFlow
An Open Source Machine Learning Framework for Everyone
-
Django
The Web framework for perfectionists with deadlines.
-
Laravel
A PHP framework for web artisans
-
D3
Bring data to life with SVG, Canvas and HTML. πππ
-
Recommend Topics
-
javascript
JavaScript (JS) is a lightweight interpreted programming language with first-class functions.
-
web
Some thing interesting about web. New door for the world.
-
server
A server is a program made to process requests and deliver data to clients.
-
Machine learning
Machine learning is a way of modeling and interpreting data that allows a piece of software to respond intelligently.
-
Visualization
Some thing interesting about visualization, use data art
-
Game
Some thing interesting about game, make everyone happy.
Recommend Org
-
Facebook
We are working to build community through open source technology. NB: members must have two-factor auth.
-
Microsoft
Open source projects and samples from Microsoft.
-
Google
Google β€οΈ Open Source for everyone.
-
Alibaba
Alibaba Open Source for everyone
-
D3
Data-Driven Documents codes.
-
Tencent
China tencent open source team.
from rlayers.