【发布时间】:2019-03-08 18:04:24
【问题描述】:
我正在关注mobx-react-router 的文档,但在尝试运行我的应用程序时,我在浏览器中收到以下错误:
Uncaught TypeError: An element descriptor's .kind property must be either "method" or "field", but a decorator created an element descriptor with .kind "undefined"
at _toElementDescriptor (app.js:49988)
at _toElementFinisherExtras (app.js:49990)
at _decorateElement (app.js:49980)
at app.js:49976
at Array.forEach (<anonymous>)
at _decorateClass (app.js:49976)
at _decorate (app.js:49958)
at Module../src/App/UserStore.js (app.js:50012)
at __webpack_require__ (bootstrap:19)
at Module../src/index.js (index.js:1)
我是这样初始化的:
const appContainer = document.getElementById('app');
if(appContainer) {
const browserHistory = createBrowserHistory()
const routingStore = new RouterStore();
const stores = {
users: userStore,
routing: routingStore
}
const history = syncHistoryWithStore(browserHistory, routingStore);
ReactDOM.render(
(
<Provider {...stores}>
<Router history={history}>
< App />
</Router>
</Provider>
),
appContainer);
}
这就是我的使用方式:
@inject('routing')
@inject('users')
@observer
class App extends Component { ...
我的UserStore:
import { observable, action, computed } from "mobx"
class UserStore {
@observable users = [];
@action addUser = (user) => {
this.users.push(user)
}
@computed get userCount () {
return this.users.length
}
}
const store = new UserStore();
export default store;
我已尝试通过 Google 搜索此错误,但它没有返回任何有用的结果。任何想法我做错了什么?
【问题讨论】:
标签: mobx mobx-react