export function UserDisplay(props) {
const {user, includeFullName} = props
const nameDisplay = includeFullName === true ? `${user.first_name} ${user.last_name}` : null
return <React.Fragment>
{nameDisplay}
</React.Fragment>
}
在这里,当我检查值时,它像这样:
const name = user.first_name
console.log(name)
它打印日志,但是在代码中不起作用,为什么?
const nameDisplay = includeFullName === true ? `${user.first_name} ${user.last_name}` : null
收到错误TypeError: Cannot read property 'first_name' of null