Answer the question
In order to leave comments, you need to log in
How to properly fetch data with conditional rendering?
Hello!
I am faced with the refinement of the site news list component in the admin panel , where in rendering I use a selection of the received data from the state, applying their conditional rendering:
{ this.state.newsList ?
this.state.newsList.map((myState) => {
<div id="news">
<header data-news={ mystate.id }>{ mystate.title }</header>
<main>{ mystate.created }</main>
<footer>Edit</footer>
</div>
}) : 'Not news matherials'
}
ReferenceError: mystate is not defined
Answer the question
In order to leave comments, you need to log in
You have a myState variable in your function, but you use it as mystate
Ps div is still not drawn
Didn't find what you were looking for?
Ask your questionAsk a Question
731 491 924 answers to any question