我有一个像这样简单的组件(屏幕/ Auth文件夹中的auth.js->),什么都不显示
while ((i = inputStream.read(byteMessage)) != -1 && socket.isConnected()) {
byteMessage = Arrays.copyOfRange(byteMessage, 0, i);
String temp = new String(byteMessage);
messageBuilder.append(temp);
if (temp.toCharArray()[i - 1] == '\r') {
Log.d(TAG, messageBuilder.toString());
messageBuilder = new StringBuilder();
}
}
我的Auth屏幕应通过react-route显示为我的初始屏幕,但不幸的是react仅显示为空白(或白屏)。
注意:正在记录以上代码段中的console.log
在我的app.js中,我有这个
const data = [
{"key":["0114","1","2013"],"values":["279"]},
{"key":["0114","1","2014"],"values":["235"]},
{"key":["0114","1","2015"],"values":["258"]},
{"key":["0114","1","2016"],"values":["274"]},
{"key":["0114","1","2017"],"values":["293"]}
];
const tableRows = data.reduce((rows, value) => {
let currentRow = rows.find(row => row.region === value.key[0] && row.gender === value.key[1]);
if (!currentRow) {
currentRow = {region: value.key[0], gender: value.key[1]};
rows.push(currentRow);
}
currentRow[value.key[2]] = value.values[0];
return rows;
}, []);
console.log(tableRows);
我的import React, { PureComponent } from 'react'
import { View, Text } from "react-native"
class Auth extends PureComponent {
console.log('Inside Login')
render () {
return (
<View>
<Text> Login </Text>
</View>
)
}
}
export default Auth
如下所示
import React, {Component} from 'react'
import {View} from 'react-native'
import AppNavigator from "./routes/routes"
export default class App extends Component {
render() {
return (
<View>
<AppNavigator />
</View>
)
}
}
而auth.js(在routes文件夹中)看起来像这样
AppNavigator
import {authNavigation} from "./auth"
import { createSwitchNavigator, createAppContainer} from "react-navigation";
const allRoutes = createSwitchNavigator(
{
authChecker: {
screen: authNavigation
}
},
{
initialRouteName: "authChecker"
}
)
const Navigator = createAppContainer(allRoutes);
export default Navigator;
是第一个代码段
答案 0 :(得分:3)
如果这可以帮助任何人,
在我的app.js中,我删除了视图
import React, {Component} from 'react'
import AppNavigator from "./routes/routes"
export default class App extends Component {
render() {
return (
<AppNavigator />
)
}
}
而且效果很好。