2016-03-14 71 views
0

我正在尝试学习Reux与Redux。 作为我选择的入门工具包"react-redux-universal-hot-example"React Redux不传递数据

我想创建一个显示一些数据的新页面。我紧跟Widgets页面,但由于某种原因,我的页面没有显示数据。

在这里我做了什么:

它一定是比较小,我失踪,但我不知道什么。

整个项目,我的变化是在这里: https://github.com/zunperior/wear4cast

回答

1

@asyncConnect装饰不会取代@connect装饰。您正在使用asyncConnect在需要时加载数据,但没有将商店中的数据连接到组件。您需要在第3行取消导入连接的注释,然后使用它将您的道具连接到redux商店。

@asyncConnect([{ 
    deferred: true, 
    promise: ({store: {dispatch, getState}}) => { 
    if (!isLoaded(getState())) { 
     return dispatch(loadOutfits()); 
    } 
    } 
}]) 
@connect(
    state => ({ 
     outfits: state.outfits.data, 
     error: state.outfits.error, 
     loading: state.outfits.loading 
    }), 
    {} 
) 
export default class Outfits extends Component { 
    static propTypes = { 
    outfits: PropTypes.string, 
    error: PropTypes.string, 
    loading: PropTypes.bool 
    }; 
    // ... 
} 
+0

谢谢泰德!这正是我所错过的。 –