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

160
Views
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 answers
Answer question

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 Report

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 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!