G
G
goodcucumber2021-07-24 14:59:38
React
goodcucumber, 2021-07-24 14:59:38

Why is text not being rendered in a React component?

There is an array of objects, each of which has its own array of objects containing text.
When outputting through the console, the text is displayed, as it should be:

console.log(this.state.cars[0].tariffs[this.state.tariffs[0]]['year']);
.
But when I start to display text from this array through the map in the component, nothing is displayed:
{this.state.cars.length && this.state.cars.map(item =>{
   return (<div key = {item.mark+item.model} className='car-block'>
         <div className='mark-model'>{item.mark} {item.model}</div>
        <div className='tar-0'>{item.tariffs.length && item.tariffs[this.state.tariffs[0]]['year']</div>
</div>)})}
. How to fix it?

Answer the question

In order to leave comments, you need to log in

Didn't find what you were looking for?

Ask your question

Ask a Question

731 491 924 answers to any question