我有以下组件呈现一系列组件.但是,我下载了React 16.2并尝试使用片段而不是div,但是我收到以下错误:
Error in ./src/containers/answers.js Syntax error: Unexpected token (24:5) 22 | 23 | return ( > 24 | <> | ^ 25 | {AnswersCard} 26 | </> 27 | )
当片段应该能够替换React 16.2中的div时,为什么会出现此错误?
question ? AnswersCard = ( question.answers.sort(function(a,b) { return (a.count < b.count) ? 1 : ((b.count > a.count) ? -1 : 0)} ).map(answer => <Answer key={answer.id} answer={answer} questionId={question.id} /> )) : AnswersCard = ( <p>Loading...</p> ) return ( <> {AnswersCard} </> ) } }