在我所有的组件中,我目前都包括这样的反应:
import React, {Component, PropTypes} from 'react'
我不明白为什么不使用它时每个人都包括React,因此想检查删除它是否安全?
JSX需要它才能工作。
基本上,JSX处理器的作用是:
<div />
到这个:
React.createElement('div')
有多种方法可以告诉它使用其他函数,例如createElement然后而不是React总是导入{createElement}-这 与 改进 相反 ,您无论如何都不应这样做。
createElement
React
{createElement}