我的地图有问题。一张react-leaflet地图。它在我加载我的网站时显示。但另一方面,就像点击链接一样,它没有。我只是在滚动时一张一张地加载左上角的图块。
以前有人遇到过这个问题吗?或者有人有什么想法?
一个例子:http : //www.noelshack.com/2019-02-1-1546872914-capture.png
import React, { Component } from 'react';
import { Map, Marker, Popup, TileLayer } from 'react-leaflet';
import 'leaflet/dist/leaflet.css';
import './local_leaflet.css';
const mapState = {
lat: 49.4431,
lng: 1.0993,
zoom: 10,
visible: true,
url: 'https://{s}.basemaps.cartocdn.com/light_all/{z}/{x}/{y}.png',
};
export default () => (
<div>
<Map center={[mapState.lat, mapState.lng]} zoom={mapState.zoom}>
<TileLayer url={mapState.url} />
</Map>
</div>
);
Run Code Online (Sandbox Code Playgroud)
我已经尝试过componentDidMount, componentDidUpdate, componentWillUnmount... 没有任何效果。
所以我试图在启动应用程序之前初始化 ExtReact 的存储,以便我可以加载数据,使用 Redux 存储更新应用程序的状态。不要被 action 的调用所迷惑,它只是用来通知 reducer 他现在可以加载 store。我正在关注本教程(http://docs.sencha.com/extreact/6.5.0/guides/extreact_stores_in_flux.html)。但我收到此错误:
Uncaught Error: Reducer "usershortcuts" returned undefined during initialization. If the state passed to the reducer is undefined, you must explicitly return the initial state. The initial state may not be undefined. If you don't want to set a value for this reducer, you can use null instead of undefined.
Run Code Online (Sandbox Code Playgroud)
所以这些是代码中最重要的部分:
index.js(入口点):
const store = configureStore();
/* Calling of actions. */
store.dispatch(usershortcutFetchDataThroughStore());
launch(
<Provider store = {store}>
<HashRouter>
<Switch> …Run Code Online (Sandbox Code Playgroud)