我是React-Native的新手。我正在尝试设置图像延迟以加载本机反应中的功能。
<Image style={{ width:250, height: 250 }}
source={require('../images/cart.png')}
onLoad={() => {
this.props.navigation.navigate('HomeScreen')
}}
/>
Run Code Online (Sandbox Code Playgroud)
我正在尝试这样做,但出现错误
onLoad={() => {
setTimeout(function(){
this.props.navigation.navigate('HomeScreen')
}, 3000);
}}
Run Code Online (Sandbox Code Playgroud) 所以,我正在尝试使用 React Navigation 并且我想在我的所有屏幕上使用相同的 Header 组件。
我用expo-cli来创建项目。
在我的MainTabNavigator.js文件中,我有一个HomeStackand SettingsStack,它们看起来像这样:
const config = Platform.select({
web: { headerMode: "screen" },
default: {}
});
const HomeStack = createStackNavigator(
{
Home: HomeScreen
},
config
);
HomeStack.navigationOptions = {
tabBarIcon: ({ focused }) => (
<NavButton
focused={focused}
name={focused ? "star" : "create"}
label={focused ? "Save" : "New"}
/>
)
};
HomeStack.path = "";
Run Code Online (Sandbox Code Playgroud)
在文件的底部,我有我的 tabNavigator
const tabNavigator = createBottomTabNavigator(
{
HomeStack,
SettingsStack
},
{
tabBarOptions: {
inactiveTintColor: "#fff", …Run Code Online (Sandbox Code Playgroud) 我正在创建一个底部选项卡栏,但没有使用内置的react-native-navigation,并且我想禁用左右滑动动画。首先,我尝试使用animationEnabled道具,但它似乎没有做任何事情。我也尝试过使用计时并将持续时间设置为 0,但也没有成功。我究竟做错了什么?
根栈.js
// import react navigation
import { NavigationContainer } from '@react-navigation/native';
import { createNativeStackNavigator } from '@react-navigation/native-stack';
// import screens
import Login from '../screens/Login';
import Signup from '../screens/Signup';
import Welcome from '../screens/Welcome';
import AccountScreen from '../screens/AccountScreen';
import NewsScreen from '../screens/NewsScreen';
import SearchScreen from '../screens/SearchScreen';
import TrendingScreen from '../screens/TrendingScreen';
import TabBarComponent from '../components/TabBarComponent';
// Colors
import {Colors} from '../components/styles';
const{brand, darkLight, primary, tertiary } = Colors;
import React, {useState} from 'react';
const Stack = createNativeStackNavigator();
const ArrowStack = () …Run Code Online (Sandbox Code Playgroud) javascript react-native react-native-navigation react-navigation
我试图在底部选项卡导航器上方显示一个媒体播放器,就像在 Spotify 应用程序中一样。它应该在所有屏幕(底部选项卡)上保持相同的状态。
有什么建议或方法可以在 React Native 中实现这一点吗?
react-native react-native-navigation react-navigation-bottom-tab
实际上,根据我的知识,我是反应本机的初学者,我有两种安装反应本机的选项,即反应本机 CLI 和 Expo CLI。我很困惑哪个更适合初学者安装和使用React Native 应用程序开发,哪个对初学者有更多的支持
reactjs react-native react-native-android react-native-navigation expo
navigation-drawer reactjs react-native react-native-android react-native-navigation