将回调传递给React中的外部加载脚本

时间:2017-12-28 18:28:26

标签: reactjs callback

出于某种原因,我不想在我的Meteor应用中使用npm或Atmosphere Google Maps套餐。并尝试直接使用谷歌地图。因此,在React组件中,我有以下渲染方法和onMapLoaded()类方法:

render(){
    return(
        <div ref={el => (this.instance = el)}>
            <p>Map</p>
            <script async defer
                    src={"https://maps.googleapis.com/maps/api/js?key=" 
                    + GoogleMapsKey 
                    + "&callback=" + ????}>
                </script>
            </div>
        );
    }

无法弄清楚,如何传递回调this.onMapLoaded函数ref,而不是它的值。

它没有公开,因为没有解释如何通过React Component&#39;脚本作为参数的方法。

0 个答案:

没有答案