My data doesn't render in the browser but logs fine? #16556
Answered
by
jamesmosier
darrylmorley
asked this question in
Help
-
Hi, I'm trying to use data from an API but my data does not render in the browser. This is my first foray into React so I'm not sure what I'm missing. Would somebody mind pointing out my error please?
The below also console.logs as expected.
|
Beta Was this translation helpful? Give feedback.
Answered by
jamesmosier
Aug 25, 2020
Replies: 1 comment 1 reply
-
{items.map((item, index) => {
console.log(item.description);
<li key={index}>{item.description}</li>
})} should be: {items.map((item, index) => {
console.log(item.description);
return <li key={index}>{item.description}</li>
})} alternatively you could replace the braces with parenthesis and then you could do it like this (which is an implicit return of you {items.map((item, index) => (
<li key={index}>{item.description}</li>
))} |
Beta Was this translation helpful? Give feedback.
1 reply
Answer selected by
darrylmorley
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
should be:
alternatively you could replace the braces with parenthesis and then you could do it like this (which is an implicit return of you
<li>...
):