为什么getDefaultProps func的defalut值会覆盖从父组件传递的值?

时间:2016-05-28 09:33:55

标签: reactjs react-native

最近,我正在尝试将本机页面转换为我的应用程序的React-native页面。我遇到了使用getDefaultProps func的疑惑问题。据我所知,当没有从父组件传入值并且有时也缓存值时,func将工作。但是当我通过isSuccessfalse并且defalut值已设置为true时,我将此属性设为true。有没有人告诉我为什么以及getDefalutProps的具体功能?

代码如下。

getDefaultProps: function() {
    return {
            displayData: {},
            bottomStyle: 0,
            isSuccess: true
        };
  },

render: function(){
        // isSuccess is true
        console.log("trade state: ", this.props.isSuccess);

很多。

0 个答案:

没有答案