Skip to content

How to avoid 'Loader must not be called again with different options' error when using nonce in useJsApiLoader? #3023

Answered by kimitaka
chrisdueck asked this question in Q&A
Discussion options

You must be logged in to vote

Choose your preferred solution below.

  • Reuse the same nonce value
  • Ensure calling useJsApiLoader only once in your app
  • Load scripts manually without useJsApiLoader (I don't recommend this)

In most cases, it's enough to load scripts only once to use Google Maps API. Twice or more would mean something technically wrong in your app.

Calling useJsApiLoader with the same nonce value, loading scripts will be just skipped, and the same API instance will be reused, so you don't worry about security holes related to loading scripts with known nonce value. And ensure calling useJsApiLoader only once in your app is a good choice too.

Sample: https://stackblitz.com/edit/cd-rgmapi-pnhl9b?file=App.tsx

I…

Replies: 12 comments 23 replies

Comment options

You must be logged in to vote
9 replies
@Ho-Ngoc-Thanh
Comment options

@chrisdueck
Comment options

@chrisdueck
Comment options

@ahmedmajidgit
Comment options

@chrisdueck
Comment options

Comment options

You must be logged in to vote
1 reply
@ahmedmajidgit
Comment options

Comment options

You must be logged in to vote
0 replies
Comment options

You must be logged in to vote
4 replies
@chrisdueck
Comment options

@Forworddash
Comment options

@JustFly1984
Comment options

@buraxta
Comment options

Comment options

You must be logged in to vote
2 replies
@chrisdueck
Comment options

@michelazzam
Comment options

Comment options

You must be logged in to vote
1 reply
@chrisdueck
Comment options

Answer selected by chrisdueck
Comment options

You must be logged in to vote
3 replies
@kimitaka
Comment options

@NazarDevsMedia
Comment options

@JustFly1984
Comment options

Comment options

You must be logged in to vote
0 replies
Comment options

You must be logged in to vote
0 replies
Comment options

You must be logged in to vote
0 replies
Comment options

You must be logged in to vote
3 replies
@JustFly1984
Comment options

@Novizh
Comment options

@Novizh
Comment options

Comment options

You must be logged in to vote
0 replies
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Category
Q&A
Labels
None yet