在React Native Windows中,导航中无法进行屏幕过渡

发布于 2025-02-10 06:36:41 字数 2827 浏览 1 评论 0原文

我正在在React Native Windows中进行屏幕过渡。

简单的按钮过渡

home->电影 - >家

不起作用。

从家到电影过渡没有问题,但是在从电影到家过渡时, 屏幕空白。

我没有收到任何错误消息,但是您能说出原因是什么吗?

环境:

    "@react-navigation/native": "^6.0.10",
    "@react-navigation/native-stack": "^6.6.2",
    "@rneui/base": "^4.0.0-rc.4",
    "@rneui/themed": "^4.0.0-rc.4",
    "react": "17.0.2",
    "react-native": "0.68.0",
    "react-native-safe-area-context": "^4.3.1",
    "react-native-screens": "^3.13.1",
    "react-native-vector-icons": "^9.1.0",
    "react-native-windows": "0.68.6"

来源:

app.js

import React from 'react';
import {NavigationContainer} from '@react-navigation/native';
import {createNativeStackNavigator} from '@react-navigation/native-stack';
import {ThemeProvider} from '@rneui/themed';

import theme from './src/styles/theme';

import Home from './src/page/Home/Home';
import Movie from './src/page/Movie/Movie';

const Stack = createNativeStackNavigator();

const App = () => {
  return (
    <NavigationContainer>
      <ThemeProvider theme={theme}>
        <Stack.Navigator>
          <Stack.Screen name="Home" component={Home} />
          <Stack.Screen name="Movie" component={Movie} />
        </Stack.Navigator>
      </ThemeProvider>
    </NavigationContainer>
  );
};

export default App;

home.js

import React from 'react';
import {StyleSheet, View, Text} from 'react-native';
import {useNavigation} from '@react-navigation/native';

import {Button} from '@rneui/themed';

const Home = () => {
  const navigation = useNavigation();
  console.log(navigation.getState());
  return (
    <View>
      <Text style={styles.centerText}>HOME</Text>
      <Button
        title="Go to Movie."
        onPress={() => navigation.navigate('Movie')}
      />
    </View>
  );
};

const styles = StyleSheet.create({
  centerText: {
    textAlign: 'center',
  },
});

export default Home;

movie.js,

import {StyleSheet, View, Text} from 'react-native';
import {useNavigation} from '@react-navigation/native';

import {Button} from '@rneui/themed';

const Movie = () => {
  const navigation = useNavigation();
  console.log(navigation.getState());
  return (
    <View>
      <Text style={styles.centerText}>MOVIE</Text>
      <Button
        title="Go to Home. "
        onPress={() => navigation.navigate('Home')}
      />
    </View>
  );
};

const styles = StyleSheet.create({
  centerText: {
    textAlign: 'center',
  },
});

export default Movie;

它是操作状态的视频。

I'm doing screen transitions in react native windows.

The simple button transition

Home-> Movie-> Home

doesn't work.

There is no problem transitioning from Home to Movie, but when transitioning from Movie to Home,
The screen goes blank.

I haven't received any error messages, but can you tell what is the cause?

environment:

    "@react-navigation/native": "^6.0.10",
    "@react-navigation/native-stack": "^6.6.2",
    "@rneui/base": "^4.0.0-rc.4",
    "@rneui/themed": "^4.0.0-rc.4",
    "react": "17.0.2",
    "react-native": "0.68.0",
    "react-native-safe-area-context": "^4.3.1",
    "react-native-screens": "^3.13.1",
    "react-native-vector-icons": "^9.1.0",
    "react-native-windows": "0.68.6"

source:

App.js

import React from 'react';
import {NavigationContainer} from '@react-navigation/native';
import {createNativeStackNavigator} from '@react-navigation/native-stack';
import {ThemeProvider} from '@rneui/themed';

import theme from './src/styles/theme';

import Home from './src/page/Home/Home';
import Movie from './src/page/Movie/Movie';

const Stack = createNativeStackNavigator();

const App = () => {
  return (
    <NavigationContainer>
      <ThemeProvider theme={theme}>
        <Stack.Navigator>
          <Stack.Screen name="Home" component={Home} />
          <Stack.Screen name="Movie" component={Movie} />
        </Stack.Navigator>
      </ThemeProvider>
    </NavigationContainer>
  );
};

export default App;

Home.js

import React from 'react';
import {StyleSheet, View, Text} from 'react-native';
import {useNavigation} from '@react-navigation/native';

import {Button} from '@rneui/themed';

const Home = () => {
  const navigation = useNavigation();
  console.log(navigation.getState());
  return (
    <View>
      <Text style={styles.centerText}>HOME</Text>
      <Button
        title="Go to Movie."
        onPress={() => navigation.navigate('Movie')}
      />
    </View>
  );
};

const styles = StyleSheet.create({
  centerText: {
    textAlign: 'center',
  },
});

export default Home;

Movie.js

import {StyleSheet, View, Text} from 'react-native';
import {useNavigation} from '@react-navigation/native';

import {Button} from '@rneui/themed';

const Movie = () => {
  const navigation = useNavigation();
  console.log(navigation.getState());
  return (
    <View>
      <Text style={styles.centerText}>MOVIE</Text>
      <Button
        title="Go to Home. "
        onPress={() => navigation.navigate('Home')}
      />
    </View>
  );
};

const styles = StyleSheet.create({
  centerText: {
    textAlign: 'center',
  },
});

export default Movie;

It is a video of the operation status.
https://drive.google.com/file/d/1-vQ4bMW_Yo7C1s8h5guohxr8FkDP1bZi/view?usp=sharing

如果你对这篇内容有疑问,欢迎到本站社区发帖提问 参与讨论,获取更多帮助,或者扫码二维码加入 Web 技术交流群。

扫码二维码加入Web技术交流群

发布评论

需要 登录 才能够评论, 你可以免费 注册 一个本站的账号。
列表为空,暂无数据
我们使用 Cookies 和其他技术来定制您的体验包括您的登录状态等。通过阅读我们的 隐私政策 了解更多相关信息。 单击 接受 或继续使用网站,即表示您同意使用 Cookies 和您的相关数据。
原文