How can you listen for specified props changes

demand is like this
has three card heads, merchandise, details, comments
and corresponding card body
now, when you click on the card head, you need to automatically move to the card body
I use the scrollTo ({x: 0Powery: 0, animated: true}) method to move
because some card bodies use redux, so you can"t use this.refs.xxx.goTop () to control movement (xxx is a component of the whole commodity or details, goTop is one of the methods. goTop () {this.refs.box.scrollTo ({x: 0J y: 0, animated: true}) , where box is a scrollView, in the product

my idea is that when clicking on the card header, in the corresponding card body, store a tag where, value in redux that is the product (commodity), details (detail), comments (evaluation)

execute
this.refs.xxx.scrollTo ({.}) in the commodity component by determining whether it is commodity in the life cycle of componentWillReceiveProps, as follows

componentWillReceiveProps(props){
    if(props.where == "commodity"){
        this.refs.xxx.scrollTo({...})
    }
}

but here"s the problem. Any props changes in this component will start this.refs.xxx.scrollTo ({.})
do you gods
have ways or ideas to just listen for where changes?
is it urgent, online, etc., thank you

.
Mar.05,2021

frankly, your question is not very clear, what kind of card body. Briefly answer what I don't think you know.
1. When a component is bound to redux by connect, you can use getWrappedInstance () to get the prototype of the component, but you need to add {withRef: true} option to connect to use it. For more information, please refer to Baidu Google keywords
2. When your subcomponents are updated frequently, you can make some simple judgments in the componentWillReceiveProps (nextProps) method. For example, when nextProps [a property]! = this.props [a property], it means that when a props is not updated to a new value (a simple string, if the object can be used with Immutable), Then do not execute the code this.refs.xxx.scrollTo ({.})
hope to help you


the question of what framework you want to bring. I have been thinking for a long time about how there is a componentWillReceiveProps life cycle in vue. Cover your face

Menu