V
V
Vanya Huk2018-04-04 16:39:32
React
Vanya Huk, 2018-04-04 16:39:32

Why can't the parent component see the value of the property?

I change the property in the child component:

setDefaultAdventureState() {

    if (this.props.filterParams.filter_models.adventure_state === 0){

      store.dispatch({

        type: 'UPDATE_ADVENTURE_STATE',
        payload: parseInt(this.state.adventure_states.off)

      });
    }else{

      store.dispatch({

        type: 'UPDATE_ADVENTURE_STATE',
        payload: parseInt(this.state.adventure_states.on)
      });

    }
  }

reducer code:
case "UPDATE_ADVENTURE_STATE":

      let filterParams = state;

      filterParams.filter_models.adventure_state = action.payload;

      return Object.assign({}, state, filterParams );

here the property has changed in the child component
5ac4d48497bd5006549412.png
and in the parent
5ac4d48497bd5006549412.png
but, I need to update the address bar, I
passed the function through props to the child component
and display props first in the child component, and then in the parent
5ac4d52060c43337708167.png
in the child adventure_state is equal to 1, and in the parent it is null, what could be problem?
returnParams() {

    console.log( this.props.filterParams )
    this.props.callbackParams();
  }

parent
getParams() {

    console.log( this.props.filterParams )

    history.pushState({}, document.title, '?' + decodeURIComponent($.param(omitEmpty(this.props.filterParams))));

  }

Answer the question

In order to leave comments, you need to log in

Didn't find what you were looking for?

Ask your question

Ask a Question

731 491 924 answers to any question