小编Rya*_*yan的帖子

反应原生 redux 不更新组件

我正在尝试使用 react native 设置 redux,但是当商店更新时它没有更新我的组件。

class Dinner extends React.Component {

    componentDidUpdate() {
        console.log('does not get called when store update');
    }

    setSelected = (meal) => {
        var index = this.props.selectedDinner.indexOf(meal);

        if (index === -1) {
            console.log('Adding meal to selected: '+meal.name);
            if (this.props.selectedDinner[0] === null) {
                var tempArr = this.props.selectedDinner;
                tempArr[0] = meal;
                this.props.setSelectedDinner(tempArr);

            } else if(this.props.selectedDinner[1] === null)  {
                var tempArr = this.props.selectedDinner;
                tempArr[1] = meal;
                this.props.setSelectedDinner(tempArr);
            } else if(this.props.selectedDinner[2] === null)  {
                var tempArr = this.props.selectedDinner;
                tempArr[2] = meal;
                this.props.setSelectedDinner(tempArr); …
Run Code Online (Sandbox Code Playgroud)

reactjs react-native redux react-redux

3
推荐指数
1
解决办法
5331
查看次数

undefined 不是一个对象(评估“route.key”)React Navigation

我无法让堆栈导航器响应本机工作。我只是制作空白堆栈导航器以进入bottomTabsNavigator。我收到一个关于使用 route.key 的错误。即使我制作了一个简单的 Stack 导航器,我仍然会收到此错误,并且似乎在网上的任何地方都看不到任何提及。任何帮助将不胜感激:)

import * as React from 'react';
import { NavigationContainer } from '@react-navigation/native';
import { createBottomTabNavigator } from '@react-navigation/bottom-tabs';
import { createStackNavigator } from '@react-navigation/stack';

import Icon from 'react-native-vector-icons/MaterialIcons';
import CartScreen from './screens/CartScreen'
import RecipeScreen from './screens/RecipeScreen'
import ProfileScreen from './screens/ProfileScreen'

const Stack = createStackNavigator();


function Navigator() {

    return (

        <NavigationContainer>

            <Stack.Navigator
                screenOptions={({ route }) => ({
                    headerStyle: {
                        backgroundColor: 'salmon',
                    },
                    headerTintColor: 'white',
                    headerTitleStyle: {
                        fontWeight: 'bold',
                    },
                })}
                tabBarOptions={{
                    showLabel: false,
                    activeTintColor: 'white',
                    inactiveTintColor: …
Run Code Online (Sandbox Code Playgroud)

react-native react-navigation react-navigation-stack react-navigation-v5

3
推荐指数
1
解决办法
977
查看次数

在 React 中使用 Leaflet js 插件

我想使用一个名为 Leaflet-geotiff ( https://github.com/stuartmatthews/leaflet-geotiff )的传单插件,但我使用的是传单反应。我可以将此插件转换为传单反应版本吗?谢谢你们。

geotiff leaflet reactjs react-leaflet

2
推荐指数
1
解决办法
1520
查看次数