久久久久久久av_日韩在线中文_看一级毛片视频_日本精品二区_成人深夜福利视频_武道仙尊动漫在线观看

    <bdo id='XXYLE'></bdo><ul id='XXYLE'></ul>

      <legend id='XXYLE'><style id='XXYLE'><dir id='XXYLE'><q id='XXYLE'></q></dir></style></legend>
    1. <small id='XXYLE'></small><noframes id='XXYLE'>

      1. <tfoot id='XXYLE'></tfoot>

        <i id='XXYLE'><tr id='XXYLE'><dt id='XXYLE'><q id='XXYLE'><span id='XXYLE'><b id='XXYLE'><form id='XXYLE'><ins id='XXYLE'></ins><ul id='XXYLE'></ul><sub id='XXYLE'></sub></form><legend id='XXYLE'></legend><bdo id='XXYLE'><pre id='XXYLE'><center id='XXYLE'></center></pre></bdo></b><th id='XXYLE'></th></span></q></dt></tr></i><div class="qwawimqqmiuu" id='XXYLE'><tfoot id='XXYLE'></tfoot><dl id='XXYLE'><fieldset id='XXYLE'></fieldset></dl></div>

        React Router Link 不適用于 LeafletJS

        React Router Link doesn#39;t work with LeafletJS(React Router Link 不適用于 LeafletJS)

        <tfoot id='1RDyQ'></tfoot>
        • <bdo id='1RDyQ'></bdo><ul id='1RDyQ'></ul>
          • <small id='1RDyQ'></small><noframes id='1RDyQ'>

                <i id='1RDyQ'><tr id='1RDyQ'><dt id='1RDyQ'><q id='1RDyQ'><span id='1RDyQ'><b id='1RDyQ'><form id='1RDyQ'><ins id='1RDyQ'></ins><ul id='1RDyQ'></ul><sub id='1RDyQ'></sub></form><legend id='1RDyQ'></legend><bdo id='1RDyQ'><pre id='1RDyQ'><center id='1RDyQ'></center></pre></bdo></b><th id='1RDyQ'></th></span></q></dt></tr></i><div class="qwawimqqmiuu" id='1RDyQ'><tfoot id='1RDyQ'></tfoot><dl id='1RDyQ'><fieldset id='1RDyQ'></fieldset></dl></div>
                    <tbody id='1RDyQ'></tbody>
                  <legend id='1RDyQ'><style id='1RDyQ'><dir id='1RDyQ'><q id='1RDyQ'></q></dir></style></legend>

                • 本文介紹了React Router Link 不適用于 LeafletJS的處理方法,對大家解決問題具有一定的參考價值,需要的朋友們下面隨著小編來一起學習吧!

                  問題描述

                  版本:

                  • react-router-dom 4.1.1
                  • react-router-redux 5.0.0-alpha.4
                  • 反應傳單 1.1.3
                  • 傳單 1.0.3

                  重現(xiàn)步驟

                  我創(chuàng)建了一張傳單地圖.我在其中添加了一些標記.這些標記有彈出窗口.在每個彈出窗口中,我都希望有一個 <Link>

                  如果有幫助,這是我的路由配置:

                  ReactDOM.render(<提供者商店={商店}>

                  <應用容器/><ConnectedRouter 歷史={歷史}>

                  <菜單容器/><開關(guān)><Route path='/:area/:sport/list' 組件={ListContainer}/><路線路徑='/:area/:sport/map' 組件={MapContainer}/><Route path='/:area/:sport/rasp' 組件={RaspContainer}/><Route path='/:shortcode/details' 組件={StationDetailsContainer}/><從='/' 重定向到='/wellington/paragliding/list'/><路由組件={NoMatch}/></開關(guān)></div></連接路由器></div></提供者>,document.getElementById('root'))

                  預期行為

                  當彈出窗口打開時,我可以看到我的鏈接并點擊它.

                  實際行為

                  無法看到鏈接.它沒有生成.

                  額外細節(jié)

                  在我的 <MapMode> 中,我使用傳單中的 <Map>.如果我在 <Map> 標簽上方設(shè)置一個 <Link> ,它就可以工作.只要我想在我的 <Map> 中有一個鏈接,它就會以某種方式中斷.這是我頁面的 React 結(jié)構(gòu),<Popup> 標簽只包含 null,因為 Javascript 正在破壞:

                  這是一個相當復雜的問題,所以請隨時向我提問.謝謝.

                  解決方案

                  我不能 100% 確定這個答案.但無論如何我都會嘗試,因為我認為至少它可能會為將來嘗試解決此問題的任何人提供一些啟示.

                  我從 react 中的 this issue 得到了第一個提示-leaflet GitHub 存儲庫.根據(jù)那個和你的錯誤,問題似乎是 Popup 無法從 context 訪問 router 因為 context 沒有傳入以他們呈現(xiàn)的方式彈出窗口.因此,如果我們可以將上下文顯式傳遞給 Popup,我們應該能夠解決問題.

                  然后我找到了一種將上下文顯式傳遞到組件中的方法 this StackOverflow 答案.有了這個,我認為你應該能夠使用如下的 HoC(高階組件)來解決你的問題.

                  這是向組件注入上下文的 HoC:

                  function withContext(WrappedComponent, context){類 ContextProvider 擴展 React.Component {getChildContext() {返回上下文;}使成為() {返回 <WrappedComponent {...this.props}/>}}ContextProvider.childContextTypes = {};Object.keys(context).forEach(key => {ContextProvider.childContextTypes[key] = React.PropTypes.any.isRequired;});返回上下文提供者;}

                  假設(shè)您在一個名為 MapMaker 的組件中使用 Popup.然后你可以像這樣使用 HoC 將帶有 router 的上下文注入到 Popup 中.

                  類 MapMaker 擴展 React.Component {//......//這確保你有路由器 this.context//您還可以添加需要傳遞到 Popup 的任何其他上下文靜態(tài)上下文類型 = {路由器:React.PropTypes.object.isRequired}使成為(){const PopupWithContext = withContext(Popup, this.context);返回 (//..... 你的 JSX 在 Popup 之前<PopupWithContext/>//用你的道具//.....彈出后你的JSX);}}

                  Versions:

                  • react-router-dom 4.1.1
                  • react-router-redux 5.0.0-alpha.4
                  • react-leaflet 1.1.3
                  • leaflet 1.0.3

                  Steps to reproduce

                  I create a leaflet map. In which I add some markers. These markers have popups. In each of these popup I want to have a <Link>

                  Also if it helps this is my Routing config:

                  ReactDOM.render(
                    <Provider store={store}>
                      <div>
                        <AppContainer />
                        <ConnectedRouter history={history}>
                          <div>
                            <MenuContainer />
                            <Switch>
                              <Route path='/:area/:sport/list' component={ListContainer} />
                              <Route path='/:area/:sport/map' component={MapContainer} />
                              <Route path='/:area/:sport/rasp' component={RaspContainer} />
                              <Route path='/:shortcode/details' component={StationDetailsContainer} />
                              <Redirect exact from='/' to='/wellington/paragliding/list' />
                              <Route component={NoMatch} />
                            </Switch>
                          </div>
                        </ConnectedRouter>
                      </div>
                    </Provider>,
                    document.getElementById('root')
                  )
                  

                  Expected Behavior

                  I can see my link and click on it when popup opens.

                  Actual Behavior

                  Impossible to see the link. It's not generated.

                  Extra details

                  Inside my <MapMode> I use <Map> from leaflet. If I set a <Link> just above the <Map> tag it works. As soon as I want to have a link inside my <Map>, somehow it breaks. This is the React structure of my page, <Popup> tag just contains null as Javascript is breaking:

                  It's quite a complex problem so feel free to ask me questions. Thanks.

                  解決方案

                  I'm not 100% sure about this answer. But anyway I'm going to try because I think at least it might shed some light to anyone who will try to solve this problem in future.

                  I got the first hint from this issue in react-leaflet GitHub repo. According to that and your error, it seems the problem is Popup can't access the router from the context because context isn't passed into the Popup with the way they render it. So we should be able to fix the problem if we can explicitly pass the context to Popup.

                  Then I found a way to explicitly pass the context into a component in this StackOverflow answer. With that, I think you should be able to use a HoC(Higher order Component) as follows to solve your problem.

                  This is the HoC that inject context to a component:

                  function withContext(WrappedComponent, context){
                  
                    class ContextProvider extends React.Component {
                      getChildContext() {
                        return context;
                      }
                  
                      render() {
                        return <WrappedComponent {...this.props} />
                      }
                    }
                  
                    ContextProvider.childContextTypes = {};
                    Object.keys(context).forEach(key => {
                      ContextProvider.childContextTypes[key] = React.PropTypes.any.isRequired; 
                    });
                  
                    return ContextProvider;
                  }
                  

                  Let's say you are using Popup inside a component called MapMaker. Then you can inject the context with router into Popup using the HoC like this.

                  class MapMaker extends React.Component {
                  
                    //......
                  
                    // This make sure you have router in you this.context
                    // Also you can add any other context that you need to pass into Popup
                    static contextTypes = {
                      router: React.PropTypes.object.isRequired
                    }
                  
                    render(){
                  
                      const PopupWithContext = withContext(Popup, this.context);
                  
                      return (
                        //..... your JSX before Popup
                        <PopupWithContext/> // with your props
                        //..... your JSX after Popup
                      );
                    }
                  
                  }
                  

                  這篇關(guān)于React Router Link 不適用于 LeafletJS的文章就介紹到這了,希望我們推薦的答案對大家有所幫助,也希望大家多多支持html5模板網(wǎng)!

                  【網(wǎng)站聲明】本站部分內(nèi)容來源于互聯(lián)網(wǎng),旨在幫助大家更快的解決問題,如果有圖片或者內(nèi)容侵犯了您的權(quán)益,請聯(lián)系我們刪除處理,感謝您的支持!

                  相關(guān)文檔推薦

                  Check if a polygon point is inside another in leaflet(檢查一個多邊形點是否在傳單中的另一個內(nèi)部)
                  Changing leaflet markercluster icon color, inheriting the rest of the default CSS properties(更改傳單標記群集圖標顏色,繼承其余默認 CSS 屬性)
                  Trigger click on leaflet marker(觸發(fā)點擊傳單標記)
                  How can I change the default loading tile color in LeafletJS?(如何更改 LeafletJS 中的默認加載磁貼顏色?)
                  Add external geojson to leaflet layer(將外部geojson添加到傳單層)
                  Adding Leaflet layer control to sidebar(將 Leaflet 圖層控件添加到側(cè)邊欄)

                    <small id='eAGwQ'></small><noframes id='eAGwQ'>

                  • <legend id='eAGwQ'><style id='eAGwQ'><dir id='eAGwQ'><q id='eAGwQ'></q></dir></style></legend>

                          <tbody id='eAGwQ'></tbody>
                          <bdo id='eAGwQ'></bdo><ul id='eAGwQ'></ul>
                          <tfoot id='eAGwQ'></tfoot>

                        • <i id='eAGwQ'><tr id='eAGwQ'><dt id='eAGwQ'><q id='eAGwQ'><span id='eAGwQ'><b id='eAGwQ'><form id='eAGwQ'><ins id='eAGwQ'></ins><ul id='eAGwQ'></ul><sub id='eAGwQ'></sub></form><legend id='eAGwQ'></legend><bdo id='eAGwQ'><pre id='eAGwQ'><center id='eAGwQ'></center></pre></bdo></b><th id='eAGwQ'></th></span></q></dt></tr></i><div class="qwawimqqmiuu" id='eAGwQ'><tfoot id='eAGwQ'></tfoot><dl id='eAGwQ'><fieldset id='eAGwQ'></fieldset></dl></div>

                            主站蜘蛛池模板: 国产成人精品一区二区三区视频 | 天天干狠狠干 | 国产精品夜夜夜一区二区三区尤 | 国产欧美一区二区三区日本久久久 | 欧洲亚洲一区二区三区 | 在线日韩 | 在线视频91 | 精品乱码一区二区 | 亚洲一区高清 | 成人在线观看亚洲 | 欧美专区在线 | 色综合欧美 | 美女视频一区二区三区 | 久久久久久亚洲精品 | 999国产视频| 国产乱码精品一区二区三区忘忧草 | 亚洲欧美日韩在线一区二区 | 久久国产精品无码网站 | 欧美日韩国产一区二区三区 | 大乳boobs巨大吃奶挤奶 | 亚洲福利在线观看 | 欧美国产精品 | 福利一区二区 | 中国美女一级黄色片 | 九九九久久国产免费 | av一二三区| 九九免费在线视频 | a在线免费观看视频 | 亚洲一区二区久久 | 最新日韩在线视频 | 欧美精品欧美精品系列 | 亚洲一区二区在线播放 | 国产日韩精品视频 | 免费观看一区二区三区毛片 | 亚洲电影在线播放 | 99伊人| 精品久久久一区 | 国产一区二区av | 日本成人中文字幕 | 手机看片169 | 三级免费 |