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

152
Visualizações
Cannot read properties of null (reading 'type')

I have a problem with the map, I do not understand why it gives me the error cannot read properties of null, the elements that are in the array also do not present any nulls so I am not understanding why this error occurs to me.

state = {
    tableHead: [
        '', 'Lunedi', 'Martedi', 'Mercoledi'
    ],
    tableData: {
        value: [
            [{ name: 'David', event1: { test: 'prova', test1: 'prova2' }}],
            [{ name: 'Lorenz', event1: { test: ['2', 'test'] }, event2: '3', event3: '4' }],
            [{ name: 'Victor', event1: { test: ['2', 'test'] }, event2: '3', event3: '4' }],
            [{ name: 'Franklyn', event1: { test: ['2', 'test'] }, event2: '3', event3: '4' }],
        ],
    },

this is my Component Render: <Table borderStyle={{ borderColor: 'transparent' }}>

                            <Row data={this.state.tableHead} style={styles.head} textStyle={styles.text} />

                            {
                                this.state.tableData.value.map((rowData, index) => {
                                    console.log('test', rowData),
                                        <TableWrapper key={index} style={styles.row}>
                                            {
                                                rowData.map((item, index) => {
                                                    console.log('item', item.name),
                                                        <Text textStyle={styles.text}>{item.name} </Text>
                                                })
                                            }
                                        </TableWrapper>
                                })
                            }

                        </Table>
                 
about 4 years ago · Juan Pablo Isaza
2 Respostas
Responde à pergunta

0

It's simple, just add ? before map. Example :

this.state.tableData?.value?.map [your code]

rowData?.map [your code]
about 4 years ago · Juan Pablo Isaza Relatório

0

WillMount

state = undefined;

DidMount:

state = <your data>;

Your render function run before state has value

Solution is: You must check data first

this.state.tableData?.value?.map
rowData?.map

Check this: Optional Chaining

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