切换视图控制器时不会触发componentWillReceiveProps

时间:2017-11-24 05:17:45

标签: react-native react-router react-redux

我正在尝试将一个值传递给基于react-native的应用程序的下一页。它正在我的应用程序的其他页面上工作。但它不适用于其中一个视图控制器。这是代码。

##这就是我称之为##

的地方
class AddProductController extends Component {
    constructor(props) {
        super(props);
        this.state = {
            avatarSource: [],
            totalImages: [],
            alreadySelect: false,
            currentUser: global.currentUser,
            position: 1,
            isLoading: false,
        };
    }

    next(){
        var advs = new Advs()
        advs.setImages(this.state.totalImages)
        console.log('days3',advs)

        Actions.addDescriptionController({advertisement:advs})
    }
}

export default AddProductController;

这是打印传递

的地方
import React, { Component } from 'react';
import { Image, Dimarketnsions, ScrollView, TouchableWithoutFeedback, TouchableOpacity, TextInput, FlatList, } from 'react-native';
import { Actions, ActionConst } from 'react-native-router-flux';
import {
  View, Container, Header, Title, Content, Text, Button, Icon, Left, Body, Right, Footer, InputGroup, Input, List, ListItem,
} from 'native-base';
import { Col, Row, Grid } from 'react-native-easy-grid';
import FooterSection, { IndexEnum } from '../../components/Footer';
import styles from './styles';
import SearchHeaderWrapper from '../../components/SearchHeaderWrapper';
import { KeyboardAwareScrollView } from 'react-native-keyboard-aware-scroll-view';

class AddDescriptionController extends Component {
    constructor(props) {
        super(props);
        this.state = {
            text: '',
            advertisement : ''
        };


    }
    componentWillMount() {

    }

    componentWillReceiveProps(nextProps) {
        console.log("pass")

    }

0 个答案:

没有答案