小编Ahs*_*Ali的帖子

如何获取当前导航状态

我正在使用来自https://reactnavigation.org/docs/navigators/tab的 React Navigation的Tab Navigator ,当我在Tab屏幕之间切换时,我在this.props.navigation中没有获得任何导航状态.

标签导航器:

    import React, { Component } from 'react';
    import { View, Text, Image} from 'react-native';
    import DashboardTabScreen from 'FinanceBakerZ/src/components/dashboard/DashboardTabScreen';
    import { TabNavigator } from 'react-navigation';


       render() {
        console.log(this.props.navigation);   

        return (
          <View>
              <DashboardTabNavigator  />
          </View>
        );
      }



    const DashboardTabNavigator = TabNavigator({
      TODAY: {
        screen: DashboardTabScreen
      },
      THISWEEK: {
        screen: DashboardTabScreen
      }
    });
Run Code Online (Sandbox Code Playgroud)

仪表板屏幕:

import React, { Component } from 'react';
import { View, Text} from 'react-native';

export default class DashboardTabScreen extends Component {
  constructor(props) …
Run Code Online (Sandbox Code Playgroud)

reactjs react-native react-redux react-navigation

8
推荐指数
2
解决办法
2万
查看次数

如何在用于设置状态值的同一函数中访问更新的状态值

class Signup extends React.Component {
  constructor() {
    super();
    this.state = { count: 0 }
  }

  hndlChange() {
    //here it's okay, It increasing count value
    this.setState({ count: this.state.count + 1 });

    //but here it printing previous value
    console.log(this.state.count);

  }
}
Run Code Online (Sandbox Code Playgroud)

我正在调用这个函数。因为它正在增加count价值,但是当我访问它时,它会返回以前的值。我想在同一个函数中访问最新的更新值,我应该怎么做。

如何在同一函数中访问最新的状态值

reactjs react-native react-redux

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

使用Moment将字符串日期转换为时间

我正在使用moment.js,我想将我的字符串日期转换为时间.

我以这种格式得到日期:Apr 01我希望输出像2017-01-01T00:00:00+05:00.

我怎样才能做到这一点?

javascript momentjs

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

通过点击&lt;TextInput /&gt;使其模糊,在本机反应中不起作用

我有<TextInput/>,我想使其模糊并在外部轻按时切换键盘,<TextInput/>我尝试了解决方案,但没有任何运气。

import React, { Component } from 'react'; import { AppRegistry, Dimensions, StyleSheet, Text, TouchableHighlight, View, Image, TextInput, ScrollView, Keyboard, TouchableWithoutFeedback } from 'react-native'; import { Button } from 'react-native-elements'; class CounterextendsComponent {

  render() {
    return (
      <View
        style={styles.container}
        onPress={this.focusOff}
      >
        <TouchableWithoutFeedback onPress={Keyboard.dismiss} accessible={false}>
          <View>
            <TextInput
              ref="numberInput"
              id={this.props.id}
              style={styles.title}
              keyboardType='numeric'
              maxLength={2}
              value={this.state.keys.toString()}
              onChange={(event) => this.updateKeysWithInputHandler(event.nativeEvent.text)}
            />
          </View>
        </TouchableWithoutFeedback>
      </View>
    );
  }
}
Run Code Online (Sandbox Code Playgroud)

javascript reactjs react-native

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