E
E
Evgeny Popov2016-06-18 14:21:32
React
Evgeny Popov, 2016-06-18 14:21:32

How to pass and update parameter value in react?

There is a parameter at the app level,
it is passed in a similar way and when render is visible:
<Header topbarVisible={this.topbarVisible} />
But when its value is updated, there is no event and the value inside the component does not change.
Question: why?

Answer the question

In order to leave comments, you need to log in

1 answer(s)
M
Maxim, 2016-06-18
@Kaaboeld

"Need more code."
However, I will assume:
a) when topbarVisible is changed "somewhere out there" - the value does not change (undefined / another property is passed, and topbarVisible remains untouched)
b) the parameter changes, but there is shouldComponentUpdate in the parent-child chain , which blocks change.
You need to check the entire chain. Where does topbarVisible change ? In this component, use console.log / debugger to see if it changes. If everything is OK, go further down the chain and look in which of the components the new props value did not come (either console.log in componentWIllReceiveProps , or the debugger step by step (the play button), or just the react developer panel in the console).
update : late noticed why you have this. topbarVisible? Isn't that a property that came in props? If you use state , it's still not clear why the property should be connected via this.

Didn't find what you were looking for?

Ask your question

Ask a Question

731 491 924 answers to any question