Empresas
Empregos
  • Sobre nós
  • Soluções
    • Publicação de vagas
      Publique sua vaga e receba candidatos qualificados em 48h.
    • Avaliações de candidatos
      Mais de 500 testes técnicos e psicológicos, mais anti-fraude.
    • Headhunting
      Busca executiva personalizada do início ao fim.
    • Folha de Pagamento + EOR
      Dispersão de folha e EOR em mais de 15 países da LATAM.
  • Preços
  • Empregos

0

124
Visualizações
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 Respostas
Responde à pergunta

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 Relatório
Responde à pergunta
Encontrar trabalhos remotos

Descubra a nova forma de encontrar um emprego!

melhores empregos
Principais categorias de trabalho
Empresas
Postar vaga Preços Comercial
Jurídico
Termos e Condições Política de privacidade
© 2026 PeakU Inc. All Rights Reserved.
Andres GPT
Recomende algumas ofertas para mim
Preciso de ajuda