import React, { Component } from 'react'
export default class DisplayTodo extends Component {
state = {
todo:["eat", "sleep", "repet"]
}
render() {
return (
<div>
{
this.state.todo.map((value)=>{
<p>{value}</p>
})
}
</div>
)
}
}
1) I know if i keep return in map it works but i want know why it failed
2)Moreover i referd to the link in for React
https://reactjs.org/docs/introducing-jsx.html#embedding-expressions-in-jsx
Now the error looks quit opposite to the explanition saying Expected an assignment or function call and instead saw an expression
3)in the react link explanation in above it is said You can put any valid JavaScript expression inside the curly braces
4) Moreover in javascript we can write like this why it is not possible in React
var a = [11,33,99]
a.map((val)=>{
console.log(val*2)
})
{value}
) ... to make use of an implicit return. Note that an implicit return only works if you have a single line of logic returning a value. For example, if you needed to create variables or log to the console, etc. then you would need to wrap your logic in curly braces and use an explicit return. – LydiaHendriks Jan 31 '20 at 19:11