Alt" connectToStores"在React / Flux App中弃用了吗?

时间:2016-04-10 06:23:44

标签: javascript reactjs flux

我正在通过教程使用React和Flux构建一个小型聊天应用程序,但是教程似乎已经过时,因为它使用的是Alt(与Flux一起使用)的方法会引发以下错误:

@connectToStores

...我相信它来自import React from 'react'; import mui from 'material-ui'; import MessageList from './MessageList.jsx'; import MessageBox from './MessageBox.jsx'; import Login from './Login.jsx'; import ChannelList from './ChannelList.jsx'; import connectToStores from 'alt/utils/connectToStores'; import ChatStore from '../stores/ChatStore'; // Material UI import * as Colors from 'material-ui/lib/styles/colors'; import AppBar from 'material-ui/lib/app-bar'; import getMuiTheme from 'material-ui/lib/styles/getMuiTheme'; @connectToStores // es7 decorator with deprecated 'connectToStores' class App extends React.Component { constructor() { super(); } static getStores() { return [ChatStore]; } static getPropsFromStores() { return ChatStore.getState(); } static childContextTypes = { muiTheme: React.PropTypes.object } getChildContext() { return { muiTheme: getMuiTheme({ primary1Color: Colors.blue500, primary2Color: Colors.blue700, primary3Color: Colors.blue100, accent1Color: Colors.pink400 }) }; } render() { var view = <Login />; if (this.props.user) { view = ( <div> <div id="content-container"> <ChannelList /> <MessageList /> </div> <MessageBox /> </div> ); } return ( <div> <AppBar title="Chat App"/> {{view}} </div> ); } } export default App; 。以下是我的代码。我调查了这个问题,看起来Alt被分解成更小的包,其中一个是Alt-React(这完全让我感到难过)。我的问题是,我如何以最新的方式使用这种方法?

ArrayList

1 个答案:

答案 0 :(得分:2)

Alt Utils库已全部移至https://github.com/altjs/utils

的单独包中

安装后

npm i --save-dev alt-utils

您可以使用以下命令访问教程所需的相同库:

import connectToStores from 'alt-utils/lib/connectToStores';
import {decorate, bind, datasource} from 'alt-utils/lib/decorators';