Business
Jobs
  • About Us
  • Solutions
    • Job Postings
      Post your job and receive qualified candidates in 48h.
    • Candidate Assessments
      500+ technical and psychological tests, plus anti-fraud.
    • Headhunting
      Tailor-made executive search from start to finish.
    • Payroll + EOR
      Payroll dispersal and EOR across 15+ LATAM countries.
  • Pricing
  • Jobs

0

122
Views
React.Children does not display children

I want to use react-native-maps-clustering but this one only takes markers which are direct children of maps.

like the example

<MapView>
  <Marker/>
  <Marker/>
</MapView>

In my case my markers are in another file nested in other elements

<MapView>
  <MarkersLayer/>
</MapView>

MarkersLayer.tsx

<Fragment>
  <Trajectory/>
 <Fragment>
  <Marker>
     <MarkerStyle/>
  <Marker/>
 </Fragment>
</Fragment>

Test : In the library - ClusteredMapView.js - l.84

      propsChildren.forEach((child, index) => {
        //my test
        if (child.type?.name == "MarkersLayer"){
          console.log('I am MarkersLayer')
          React.Children.forEach(child, ch => {
            console.log("child MarkersLayer", ch)
          })
        }else if (child.props.coordinate){
          console.log("I am a marker", child)
        }
         //end
        if (isMarker(child)) {
          rawData.push(markerToGeoJSONFeature(child, index));
        } else {
          otherChildren.push(child);
        }
      });

Children in MapView :

enter image description here

Children in MarkerLayer :

enter image description here

Test : In my MarkerLayer component

  const propsChildren = useMemo(
    () => React.Children.toArray(children),
    [children],
  );

Result :

enter image description here

The library uses React.Children to find the children contained in MapView but I can't get the markers in MarkerLayer.

Thanks for the people reading this post and for the answers :)

about 4 years ago · Juan Pablo Isaza
1 answers
Answer question

0

Try using useState() and useEffect().

This is done like so:

const [children, setChildren] = useState([]);

useEffect(() => {
    setChildren(React.Children.toArray(children))
}, []);
about 4 years ago · Juan Pablo Isaza Report
Answer question
Find remote jobs

Discover the new way to find a job!

Top jobs
Top job categories
Business
Post vacancy Pricing Sales
Legal
Terms and conditions Privacy policy
© 2026 PeakU Inc. All Rights Reserved.
Andres GPT
Show me some job opportunities
There's an error!