preface

A few days ago, I wrote a project using React-Native. I encountered a lot of problems, which are recorded here 📝 to avoid forgetting. This article will be updated from time to time!

The problem summary

Problem a

Remote debugger is in a background TAB which may cause apps to perform slowly

Keep that Chrome Tab at the front of the page and don’t minimize the window.

Question 2

The connection tohttp://localhost:8081Red error

The solution is this is amazing. ⌘ to a few more pushes or to delete items on the simulator and reload will generally resolve this.

bad news: Metro V0.29.0 won’t work with RN 0.54 to 0.55 because it introduced a new config param that RN is not handling yet (we’re working on improving configuration compatibility between RN and metro).

good news: the actual fix needed to solve this issue is in the RN repo (7be3d1c), so cherry-picking it into the 0.54 and 0.55 branches and releasing a RN minor version will fix this. (cc @hramos, @grabbou ).

Or use the following command to resolve the problem

yarn cache clean&&yarnCopy the code

Question 3

The Runtime is not ready for debugging error appears in red

Two solutions

  1. Turn off the http://localhost:8081/debugger-ui/ open again
  2. Press Command + D to disable Debug JS Remotely

Problem four

Unrecognized font family red alarm

The solution is entered on the terminal

react-native link react-native-vector-iconsCopy the code

Then restart it

Problem five

React Native does not automatically calculate the size of views such as images

details

Question 6

Random Violation red alert appears in react-native Interactable

React-native version 0.53.0. See Wix/React-Native Interface #185

Question 7

‘No Bundle URL present’ error is encountered after Build

Solution Disable SS and VPN services and re-install react-native run-ios. Amazing…

There is also an official issue

Question 8

RegeneratorRuntime is not defined

The solution

react-native start --reset-cacheCopy the code

The final reason is that a component was not deleted 🤣

Question 9

Error :CFBundleIdentifier “, Does Not Exist

The solution

Opening Xcode to run the project appears



There is a libinteractable. a in there, just delete it

Reference: rebeccahughes/react – native – device – info# 251

Question 10

Precautions for deleting a package

React-native unlink yarn remove

You have to do this or there will be problems…

Question 11

Random Violation: View config not found for name red alert

The solution stackoverflow.com/questions/4…

The problem.

Button components cannot directly use style to set width and height, etc

The solution

If this button doesn’t look right for your app, you can build your own button using TouchableOpacity or TouchableNativeFeedback.

That is, you can use the TouchableOpacity or TouchableNativeFeedback component instead

Question 13

Error using TouchableWithoutFeedback

This component must have at least one child. If it is multiple, it must be wrapped in a View. I can write it like this

render() { return( <TouchableWithoutFeedback style={{flex: 1}} onPress={dismissKeyboard}> <View style={{flex: 1}}>...... </View> </TouchableWithoutFeedback> ); }Copy the code

Question 14

Showing All Messages Code signing is required for product type ‘Unit Test Bundle’ in SDK ‘iOS 11.2’

In Xcode



Can be

Question 15

React-navigation TabNavigator is slow to switch when clicking.

When debugging the TabNavigator of the React-Navigation on a real phone, clicking TAB always feels very slow. After trying for a long time, it takes about 0.5 seconds to switch and the experience is very bad.

Solution Disable the debug mode…

Question 16

React Navigation TabNavigator Indicates the delay of a frame

The TAB ICONS below have a frame delay from the first icon to the second icon when the page loads

The solution defines initialLayout to prevent the delay of a frame in the react-native Tab-View rendering

Reference: github.com/react-nativ…

Question 17

Timed out waiting for a red alert

Solution Restart the simulator…

Question 18

React Native does not have a \ component newline

The solution

You can write {‘ \n ‘} in the Text component, as in:

The problem of the 19th

The React Native CheckBox component is only available for Android

The solution is to use this github.com/crazycodebo…

Question 20

Add the click event to the headerRight of react- Navigation

The workaround first requires dynamically adding click events to componentDidMount(){}

componentDidMount(){
    this.props.navigation.setParams({
        navigatePress:this.navigatePress
    })
}Copy the code

then

NavigatePress = () => {alert(' click on headerRight'); console.log(this.props.navigation); }Copy the code

Now you can use the params method to retrieve the click event.

static navigationOptions = ({ navigation, screenProps }) => ({ title: navigation.state.params? navigation.state.params.title:null, headerRight:( <Text onPress={navigation.state.params? Navigation. State. Params. NavigatePress: null} > back < / Text >)});Copy the code

Question 21.

React-navigation TAB click StatusBar color problem

The solution details reactnavigation.org/docs/status…

Question 22

The Image tag does not support HTTP

The solution

For ios 9 and above, Https is the default request. To support Http, modify the info.plist file to add key-value pairs

Question 23

React-native swiper dynamic data rendering, page-turning confusion

At the beginning of the use of static data, no problem, but the use of dynamic loading data problems, after some debugging found, may be index problem, in github library search issue sure enough someone encountered this problem github.com/leecade/rea…

The solution



Add key values to youGets the length of the data

Question 24

The react-native swiper index has a bug.

At the beginning

When turning the page, there was a problem of random index change. At that time, I looked at the API and there was no problem until I located it

The title will not display the index found no problem, not random page flipping… “, and then on a page to see the title is relatively large, shaking, resulting in random page turning, and then look inside there are numbers and text, size is not the same, set the font is good… React-native swiper page flipping may be triggered by jitter, resulting in random page flipping. God pit bug, looking for 4 or 5 hours… 😡

Question 25.

Invalid ListView, FlatList, Sections and VirtualizedList paddingBottom.

ListView, FlatList, Sections, and VirtualizedList inherit from ScrollView and cause this problem

The solution

<ScrollView contentContainerStyle={{paddingBottom: 16}} />Copy the code

Question 26

A red alert appears that could not connect to Development Server

Solution Turn off VPN, or do not turn on global mode… It’s amazing