ReactNative.createClass is not recommended to use React.createClass from the React package

Does anyone know why this warning lights up?

another warning: ReactNative.createElement is deprecated. Instead, use "React.createElement" instead of the "reactive" package.

Code:

var React = require('react-native'); var { Text, View, StyleSheet, } = React; module.exports = React.createClass({ render: function(){ return( <View> <Text>{this.props.titleName}</Text> </View> ); } }); var styles = StyleSheet.create({ container:{ }, text:{ } }); 
+6
source share
1 answer

Importing React from response-native was deprecated in 0.25.1 . It will stop working at 0.26.

You should do it now:

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

Change If you still get obsolescence warnings after fixing the code, you are probably using dependencies that are not yet updated. To fix these warnings, follow these steps:

  • Check if there are updates available that fix the import.
  • Use this script to rewrite your dependencies to automatically use the correct import. This will take quite a while and rewrite some files that have nothing to do with the reaction. jscodeshift -t transform.js PATH_TO_YOUR_PROJECT/node_modules/
  • To find the remaining files that require React from-response-native actions, you can set a breakpoint in node_modules / react-native / Libraries / ReactNative / ReactNative.js on line 41, where a warning is raised.

When you find a dependent that has not been updated, it is probably a good idea to submit a question or if you have PR time.

+18
source

All Articles