首页 > Web开发 > 详细

React JSX file giving error “Cannot read property 'createElement' of undefined”

时间:2021-08-10 16:47:41      阅读:17      评论:0      收藏:0      [点我收藏+]
import { assert } from ‘assert‘;
import { MyProvider } from ‘../src/index‘;
import { React } from ‘react‘;

const myProvider = (
  <MyProvider>
  </MyProvider>
);

describe(‘Array‘, function() {
  describe(‘#indexOf()‘, function() {
    it(‘should return -1 when the value is not present‘, function() {
      assert.equal(-1, [1,2,3].indexOf(4));
    });
  });
});
245
 

To import React do import React from ‘react‘ You add brackets when the thing you are importing is not the default export in that module or file. In case of react, it‘s the default export.

This might apply to your other imports depending on how you defined them.

import React, { Component } from ‘react‘
改为
import * as React from ‘react‘;

React JSX file giving error “Cannot read property 'createElement' of undefined”

原文:https://www.cnblogs.com/sexintercourse/p/15123119.html

(0)
(0)
   
举报
评论 一句话评论(0
关于我们 - 联系我们 - 留言反馈 - 联系我们:wmxa8@hotmail.com
© 2014 bubuko.com 版权所有
打开技术之扣,分享程序人生!