使用React模块导出方法不正确

时间:2016-06-05 22:04:42

标签: reactjs coffeescript

为什么我

  

React.createElement:type不应为null,undefined,boolean或number。

     

未捕获的不变违规:元素类型无效:期望一个字符串(对于内置组件)或类/函数(对于复合组件)但得到:object。检查private static final String INDEX_NAME = "locations"; private static final Map<String, String> CONFIG = SpatialIndexProvider.SIMPLE_POINT_CONFIG; private static final String LAT = CONFIG.get(LayerNodeIndex.LAT_PROPERTY_KEY); private static final String LON = CONFIG.get(LayerNodeIndex.LON_PROPERTY_KEY); @Override public Void beforeCommit(TransactionData data) throws Exception { Index<Node> index = getGraphDatabaseService().index().forNodes(INDEX_NAME, CONFIG); Node originalNode = <...>; if (originalNode.hasProperty(LAT) && originalNode.hasProperty(LON)) { index.add(originalNode, null, null); } else { deleteProxyNode(originalNode.getId()); } return null; } private void deleteIndexedProxyNode(long originalNodeId) { String query = "" + "MATCH (:ReferenceNode)-[:LAYER]-()-[:RTREE_ROOT]-()-[*..]-(n {id:{id}}) " + "MATCH (n)-[r:RTREE_REFERENCE]-() " + "DELETE r, n"; Map<String, Object> parameters = new HashMap<>(); parameters.put("id", originalNodeId); getGraphDatabaseService().execute(query, parameters); } 的呈现方法。

尝试从文件导入我的模块时?我有以下结构:

  • app.cjsx
    • 组件/
    • index.coffee
    • 应用/
      • App.cjsx
      • index.coffee

app.cjsx:

Main

部件/ index.coffee:

React = require('react')
ReactDOM = require('react-dom')
injectTapEventPlugin = require('react-tap-event-plugin')
{getMuiTheme, MuiThemeProvider} = require('material-ui/styles')
App = require('./components/App')
injectTapEventPlugin()

Main = React.createClass
  render: ->
    <MuiThemeProvider muiTheme={getMuiTheme()}>
      <App />
    </MuiThemeProvider>

ReactDOM.render(
  <Main />,
  document.getElementById('app')
)

组件/应用/ index.coffee:

exports.App = require('./App')

组件/应用/ App.cjsx:

require('coffee-react/register')
module.exports = require('./App.cjsx')

我正在使用React = require('react') AppBar = require('material-ui/AppBar') {Card, CardHeader, CardText} = require('material-ui/Card') exports.default = React.createClass render: -> <AppBar title='Hello, world!' /> coffee-react v5.0.0

1 个答案:

答案 0 :(得分:0)

好吧,经过数小时杀死我的大脑试图想出我的出口无法正常工作的几个小时后,我发现错误不在我的导出中,而是我导入Material UI AppBar的方式:

AppBar = require('material-ui/AppBar')

所以我把它改成了

{AppBar} = require('material-ui')