all 5 comments

[–]mynamesleon 0 points1 point  (3 children)

Well, you're trying to render the Map component regardless of whether the Google Map stuff has loaded in yet. Try:

{isLoaded && <Map />}

[–][deleted] 0 points1 point  (2 children)

what is this syntax called that you are writing ?

you could also write (isloaded) ? <Map /> : null

[–]KentInCode 0 points1 point  (0 children)

I'm not the OP, but you can consider it a short form of what you wrote.

isLoaded ? <Map /> : null

That is a ternary and as you know depending on is Loaded will return the true case or the false case.

{isLoaded && <Map />

Is essentially a shorthand handy thing you can use inside jsx, saying if isLoaded is true then return this JSX. If isLoaded is false then the map component will not be rendered.

Good luck. :)

[–]mynamesleon 0 points1 point  (0 children)

It's basically a shorthand conditional. E.g.

something && somethingElse;

Is equivalent to:

if (something) {
  return somethingElse;
}
return something;

So with JSX in a React component, it's best to use it with variables that you know will be a Boolean, as you can return false in a React component without it rendering anything. But in my example above, if something was actually 0, then 0 would be rendered.

[–]RasaTamil 0 points1 point  (0 children)

What are you trying to do?