How to load the google maps api [removed] in my react app only when it is required?

前端 未结 3 462
渐次进展
渐次进展 2021-01-04 13:04

I want to try and use the google maps API to show a map but I\'m wondering if there\'s a better way to load the

3条回答
  •  情歌与酒
    2021-01-04 13:43

    Yet another package react-dependent-script package to load Google Maps libraries, which provides the following features:

    • ensure to load the JavaScript and/or CSS first, then render your content
    • ensures the external content is only loaded once, regardless of how many times the render() function is called

    Here is a simple example, where you wrap your map component in ReactDependentScript component:

    
          
    
    

    Here is a demo for your reference

提交回复
热议问题