Javascript 反应,雷杜。DOM更新,但在Chrome中没有回流
我的代码在React中。因此,在一个组件中,比如AppViewerEvents,我正在画布中处理mouseMove事件。它在画布上获取当前鼠标指针坐标,并发送redux操作,该操作只需使用新值更新Javascript 反应,雷杜。DOM更新,但在Chrome中没有回流,javascript,reactjs,redux,dom-events,cesium,Javascript,Reactjs,Redux,Dom Events,Cesium,我的代码在React中。因此,在一个组件中,比如AppViewerEvents,我正在画布中处理mouseMove事件。它在画布上获取当前鼠标指针坐标,并发送redux操作,该操作只需使用新值更新坐标对象 <ScreenSpaceEvent type={Cesium.ScreenSpaceEventType.MOUSE_MOVE} action={(e: CesiumMovementEvent) => {
坐标
对象
<ScreenSpaceEvent
type={Cesium.ScreenSpaceEventType.MOUSE_MOVE}
action={(e: CesiumMovementEvent) => {
const position = scene?.pickPosition(e.endPosition!);
if (position) {
const cartographic = Cesium.Cartographic.fromCartesian(position);
const longitude = Cesium.Math.toDegrees(cartographic.longitude);
const latitude = Cesium.Math.toDegrees(cartographic.latitude);
dispatch(setCoordinates({ longitude, latitude, elevation: cartographic.height }));
}
}}
/>
{
const position=场景?.pickPosition(例如endPosition!);
如果(职位){
常量制图=笛卡尔坐标(位置)的铯制图;
常数经度=铯。数学到度数(制图经度);
常数纬度=铯。数学到度数(制图纬度);
调度(设置坐标({经度、纬度、高程:magraphic.height}));
}
}}
/>
reducer每次都以惊人的速度处理此操作,因此redux不是问题所在。
在另一个组件CoordinatesBar中,我通过useSelector订阅了这段存储,并在JSX中呈现了这个坐标,如下所示:
const { coordinates } = useSelector(state => state.projectView);
...
<div className='coord'>
<span className='spacer'>
{${coordinates.longitude?.toFixed(numberOfDigits)}° N`}
</span>
</div>
<div className='line' />
<div className='coord'>
<span className='spacer'>
{${coordinates.latitude?.toFixed(numberOfDigits)}° E`}
</span>
</div>
const{coordinates}=useSelector(state=>state.projectView);
...
{${坐标.经度?.toFixed(numberOfDigits)}N`}
{${坐标.纬度?.toFixed(numberOfDigits)}E`}
问题是:如果我在devtools元素选择器中检查我的页面,我可以看到每次触发事件时DOM都在更新(范围值发生变化),并且动作也按预期调度。但我看不到页面本身的“重画”或回流。只有当我停止移动鼠标并触发事件时,才会发生这种情况。此外,Firefox不是这样,只有Chrome。
求求你,我已经在谷歌上搜索了3天了,什么都没有