Internet Explorer не может скомпилировать внешний компонент реакции: объекты недопустимы как дочерний элемент React - PullRequest
0 голосов
/ 07 мая 2018

У меня проблема с React в Internet Explorer 11.

Я получаю ошибку

Объекты недопустимы как дочерние элементы React (найдено: объект с ключами {$$ typeof, type, key, ref, props, _owner}).

Подробно о: https://reactjs.org/docs/error-decoder.html?invariant=31&args[]=object%20with%20keys%20%7B%24%24typeof%2C%20type%2C%20key%2C%20ref%2C%20props%2C%20_owner%7D&args[]=

при использовании внешнего реагирующего компонента.

Позвольте мне показать небольшой код:

node_modules / доля Пб / SRC / компоненты / ExternalComponent.js

import React from 'react';

   class ExternalComponent extends React.PureComponent {

     render() {
       return (
         <div>ExternalComponent</div>
       )
     }
   }

  export default ExternalComponent;

Footer.js

import React from 'react';
import ExternalComponent from 'share-lib/src/components/ExternalComponent';

class Footer extends React.PureComponent {
   render() {
      return (
          <ExternalComponent />
      );
   }
}

export default Footer;

Я использую Babel. Также попробовал babel-polyfill (не работает, но я могу сделать что-то не так, точно не знаю)

Как мне избавиться от ошибки:

Объекты недопустимы в качестве дочерних элементов React (найдено: объект с ключами {$$ typeof, type, key, ref, props, _owner}). ?

Только в Internet Explorer и только с внешними модулями

Вот мой .babelrc

        {
       "presets": [
         [
          "@babel/preset-env",
          {
             "targets": {
                "node": "current"
              },
              "useBuiltIns": "usage"
          }
        ],
        "@babel/preset-react"
        ],
      "plugins": [
        "es6-promise",
        "transform-flow-strip-types",
        "@babel/plugin-proposal-object-rest-spread",
        "@babel/plugin-proposal-class-properties",
        "@babel/plugin-proposal-function-bind",
        "@babel/plugin-transform-object-assign",
        "@babel/plugin-proposal-export-default-from"
      ]
    }

Вот несколько версий моих пакетов:

"react": "16.2.0"
"react-dom": "16.2.0",
"babel-loader": "8.0.0-beta.0",
"@babel/core": "^7.0.0-beta.37",
"@babel/preset-env": "^7.0.0-beta.37",
"@babel/preset-react": "^7.0.0-beta.37",
...