Empresas
Empleos
  • Sobre nosotros
  • Soluciones
    • Publicación de vacantes
      Publica tu vacante y recibe candidatos calificados en 48h.
    • Evaluación de candidatos
      500+ pruebas técnicas y psicológicas, más anti-fraude.
    • Headhunting
      Búsqueda ejecutiva a la medida de principio a fin.
    • Nómina + EOR
      Dispersión de nómina y EOR en más de 15 países de LATAM.
  • Precios
  • Empleos

0

123
Vistas
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 Respuestas
Responde la pregunta

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 Denunciar
Responde la pregunta
Encuentra empleos remotos

¡Descubre la nueva forma de encontrar empleo!

Top de empleos
Top categorías de empleo
Empresas
Publicar vacante Precios Comercial
Legal
Términos y condiciones Política de privacidad
© 2026 PeakU Inc. All Rights Reserved.
Andres GPT
Recomiéndame algunas ofertas
Necesito ayuda