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

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”

上一篇:微信公众平台开发(71)OAuth2.0网页授权


下一篇:记录一次Https请求的报异常请求被中止: 未能创建 SSL/TLS 安全通道的问题