Javascript 网页包可以';不加载高阶组件?

Javascript 网页包可以';不加载高阶组件?,javascript,reactjs,higher-order-components,Javascript,Reactjs,Higher Order Components,我创建了一个高阶组件,如下所示: import * as React from 'react' export const ForceMobileHOC = WrappedComponent => { return class extends React.Component { constructor(props) { super(props) } render() { return ( <WrappedCompo

我创建了一个高阶组件,如下所示:

import * as React from 'react'

export const ForceMobileHOC = WrappedComponent => {
  return class extends React.Component {
    constructor(props) {
      super(props)
    }

    render() {
      return (
        <WrappedComponent {...this.props} />
      )
    }
  }
}

我以前做过HOC,但从来没有遇到过这样的事情。发生了什么事?

这是进口货。我试图导入
ForceMobileHOC.JS
而不是
ForceMobileHOC.JS
。不确定为什么会出现这样的错误,但这就是解决方案。

它似乎被JSX搞糊涂了。你的网页配置是什么样子的?特别是,您对
.jsx
文件(或此文件具有的任何文件扩展名)使用的加载程序是什么?@NicholasTower很好。已使用网页包配置更新问题。。。
Module parse failed: Unexpected token (45:13)
You may need an appropriate loader to handle this file type, currently no loaders are configured to process this file. See https://webpack.js.org/concepts#loaders
| 
|     render() {
>       return <WrappedComponent {...this.props} />
|     }
|   }
module: {
    rules: [
      {
        test: /\.js$/,
        loader: 'babel-loader',
        exclude: /core-js/,
        query: {
          cacheDirectory: './webpack_cache/'
        }
      }
    ]
  }