return FALSE; $r = well_tag_thread__update(array('id' => $id), $update); return $r; } function well_tag_thread_find($tagid, $page, $pagesize) { $arr = well_tag_thread__find(array('tagid' => $tagid), array('id' => -1), $page, $pagesize); return $arr; } function well_tag_thread_find_by_tid($tid, $page, $pagesize) { $arr = well_tag_thread__find(array('tid' => $tid), array(), $page, $pagesize); return $arr; } ?>javascript - Optional-Chaining does not work in create-react-app - Stack Overflow
最新消息:雨落星辰是一个专注网站SEO优化、网站SEO诊断、搜索引擎研究、网络营销推广、网站策划运营及站长类的自媒体原创博客

javascript - Optional-Chaining does not work in create-react-app - Stack Overflow

programmeradmin1浏览0评论

In a create-react-app project, I am using @babel/plugin-proposal-optional-chaining in my `.babelrc

However, I have this error: Module parse failed: Unexpected token (22:16) You may need an appropriate loader to handle this file type.

This is all my babel dependencies:

{
  "dependencies": {
    "@babel/core": "^7.9.0",
    "@babel/node": "^7.8.7",
    "@babel/plugin-external-helpers": "^7.8.3",
    "@babel/plugin-proposal-class-properties": "^7.8.3",
    "@babel/plugin-proposal-decorators": "^7.8.3",
    "@babel/plugin-proposal-json-strings": "^7.8.3",
    "@babel/plugin-proposal-object-rest-spread": "^7.9.5",
    "@babel/plugin-proposal-optional-chaining": "^7.9.0",
    "@babel/plugin-syntax-dynamic-import": "^7.8.3",
    "@babel/plugin-syntax-import-meta": "^7.8.3",
    "@babel/plugin-transform-async-to-generator": "^7.8.3",
    "@babel/plugin-transform-modules-monjs": "^7.9.0",
    "@babel/plugin-transform-react-constant-elements": "^7.9.0",
    "@babel/plugin-transform-react-inline-elements": "^7.9.0",
    "@babel/plugin-transform-runtime": "^7.9.0",
    "@babel/polyfill": "^7.8.7",
    "babel-plugin-add-module-exports": "^1.0.2",
    "babel-plugin-array-includes": "^2.0.3",
    "babel-plugin-inline-react-svg": "^1.1.1"
  }
}
  • node v14.0.0
  • npm 6.14.4
  • react-scripts 2.1.8

What else do I need in order to get this to work?

In a create-react-app project, I am using @babel/plugin-proposal-optional-chaining in my `.babelrc

However, I have this error: Module parse failed: Unexpected token (22:16) You may need an appropriate loader to handle this file type.

This is all my babel dependencies:

{
  "dependencies": {
    "@babel/core": "^7.9.0",
    "@babel/node": "^7.8.7",
    "@babel/plugin-external-helpers": "^7.8.3",
    "@babel/plugin-proposal-class-properties": "^7.8.3",
    "@babel/plugin-proposal-decorators": "^7.8.3",
    "@babel/plugin-proposal-json-strings": "^7.8.3",
    "@babel/plugin-proposal-object-rest-spread": "^7.9.5",
    "@babel/plugin-proposal-optional-chaining": "^7.9.0",
    "@babel/plugin-syntax-dynamic-import": "^7.8.3",
    "@babel/plugin-syntax-import-meta": "^7.8.3",
    "@babel/plugin-transform-async-to-generator": "^7.8.3",
    "@babel/plugin-transform-modules-monjs": "^7.9.0",
    "@babel/plugin-transform-react-constant-elements": "^7.9.0",
    "@babel/plugin-transform-react-inline-elements": "^7.9.0",
    "@babel/plugin-transform-runtime": "^7.9.0",
    "@babel/polyfill": "^7.8.7",
    "babel-plugin-add-module-exports": "^1.0.2",
    "babel-plugin-array-includes": "^2.0.3",
    "babel-plugin-inline-react-svg": "^1.1.1"
  }
}
  • node v14.0.0
  • npm 6.14.4
  • react-scripts 2.1.8

What else do I need in order to get this to work?

Share Improve this question edited Apr 26, 2020 at 12:31 Dennis Vash 54k12 gold badges117 silver badges132 bronze badges asked Apr 26, 2020 at 11:47 Dimitri KopriwaDimitri Kopriwa 14.4k33 gold badges116 silver badges232 bronze badges
Add a ment  | 

1 Answer 1

Reset to default 6

You only need to make sure you have installed react-scripts 3.3.0+ version as it already es with optional chaining built-in:

const obj = { a: `Hello` };

// Hello World
const App = () => {
  return (
    <>
      {obj?.a}
      {obj?.b ?? ` World`}
    </>
  );
};

发布评论

评论列表(0)

  1. 暂无评论