question-mark
Stuck on an issue?

Lightrun Answers was designed to reduce the constant googling that comes with debugging 3rd party libraries. It collects links to all the places you might be looking at while hunting down a tough bug.

And, if you’re still stuck at the end, we’re happy to hop on a call to see how we can help out.

UserLocation passed children not rendered

See original GitHub issue

Describe the bug Pass a child into UserLocation isn’t rendered.

To Reproduce I’ve tried several iterations, however I believe this is how the api is supposed to be used? Correct me if I’m wrong:

<MapboxGL.UserLocation
  renderMode="custom"
  visible
  animated
  onUpdate={myUserLocationUpdateCallback}
>
  <View style={{ height: 10, width: 10, backgroundColor: 'red' }} />
</MapboxGL.UserLocation>

Expected behavior Passed child is rendered

Versions:

  • Platfrom: Android
  • Device: LG Q7
  • OS: Android 8
  • React Native Version [0.61.2]

Additional context Maybe I’m supposed to pass it in another way or set other props correctly?

Issue Analytics

  • State:closed
  • Created 4 years ago
  • Comments:14 (8 by maintainers)

github_iconTop GitHub Comments

3reactions
kristfalcommented, Nov 7, 2019

Hey,

native components such as views can’t be passed as children inside the MapView. Only mapbox-gl-native components can.

I’m guessing you want to pass in a symbol layer with an icon or something. If that is the case, you can do something like:

<MapboxGL.UserLocation renderMode={'custom'}>
  <MapboxGL.SymbolLayer
    id={'custom-user-symbol'}
    style={{
      iconImage: 'your-icon',
      iconRotationAlignment: 'map',
      iconAllowOverlap: true,
    }}
  />
</MapboxGL.UserLocation>

your-icon needs to be loaded like any other mapbox icon.

1reaction
ako977commented, Apr 13, 2021

Just to tie this altogether. I now know why I was not getting the custom icon. The culprit was including this prop: renderMode={'custom'}.

Basically I was following the old docs which expected ‘custom’. However in the latest version of the library, this makes the userLocation marker simply disappear.

Changing renderMode to ‘normal’ or removing the prop completely solves the problem.

Thank you

Read more comments on GitHub >

github_iconTop Results From Across the Web

UserLocation passed children not rendered #511 - GitHub
Pass a child into UserLocation isn't rendered. To Reproduce I've tried several iterations, however I believe this is how the api is supposed...
Read more >
Why, in React, do children not re-render when parent ...
Your problem is that you are considering code like function ComponentToRender() { const count = React.useRef(0) React.
Read more >
Using React Portals to Render Children Outside the DOM ...
Say we need to render a child element into a React application. Easy right? That child is mounted to the nearest DOM element...
Read more >
Slow rendering - Android Developers
UI Rendering is the act of generating a frame from your app and displaying it on the screen. To ensure that a user's...
Read more >
How to get user's location with React JS - DEV Community ‍ ‍
In this article, we're not going to use any 3rd party library, Just Geolocation API. First, create your react app using this command,....
Read more >

github_iconTop Related Medium Post

No results found

github_iconTop Related StackOverflow Question

No results found

github_iconTroubleshoot Live Code

Lightrun enables developers to add logs, metrics and snapshots to live code - no restarts or redeploys required.
Start Free

github_iconTop Related Reddit Thread

No results found

github_iconTop Related Hackernoon Post

No results found

github_iconTop Related Tweet

No results found

github_iconTop Related Dev.to Post

No results found

github_iconTop Related Hashnode Post

No results found