Nic*_*s O 0 javascript arrays if-statement function reactjs
在遵循我在网上找到的一些代码示例时,我遇到了一个意外错误。我假设我犯了一些错误,但与这里的其他示例相比,我找不到错误。我试图在 map 函数中包含一个 if 函数:
const compProfileRemoveHandler = compProfileId => {
todoList.map(profile =>(
if (profile.id !== compProfileId) {some code}
))};
Run Code Online (Sandbox Code Playgroud)
有谁知道我为什么会收到以下错误:“解析错误:意外的令牌”(并且在语句下标记了“if”)。
非常感谢您的帮助!
尝试这个:
const compProfileRemoveHandler = compProfileId => {
todoList.map(profile => {
if (profile.id !== compProfileId) {some code}
} )};
Run Code Online (Sandbox Code Playgroud)