ReactNative.createElement is deprecated. Use React.createElement from the "react" package instead.

前端之家收集整理的这篇文章主要介绍了ReactNative.createElement is deprecated. Use React.createElement from the "react" package instead.前端之家小编觉得挺不错的,现在分享给大家,也给大家做个参考。

最近在调试RN时出现一个黄色警报框,内容是:Warning: ReactNative.createElement is deprecated. Use React.createElement from the “react” package instead.

查了下一些资料。发现问题是React Native在升级到0.25.1版本后修改了导入方式。具体如下:

Deprecations

Requiring React API from react-native is now deprecated - 2eafcd4 0b534d1
Instead of:

import React,{ Component,View } from 'react-native';

you should now:

import React,{ Component } from 'react';
import { View } from 'react-native';

就是说之前是全部通过react-native来导入的,但是现在除了View通过react-native来导入外,其他都通过react来导入。
具体详情可以看react-native 0.25版本更新日志

原文链接:https://www.f2er.com/react/306812.html

猜你在找的React相关文章