【发布时间】:2016-10-10 09:00:58
【问题描述】:
我刚开始使用 reactjs,并尝试为我的 jsx 进行热重载。我分叉了这个应用程序:https://github.com/gaearon/react-hot-boilerplate/tree/next。
我将 app.js 稍微更改为:
import React, { Component } from 'react';
export default class App extends Component {
constructor(){
super();
this.state = {
txt: 'this is the txt',
cat: 0
}
}
render() {
return (<div>
{this.state.txt}
<h1>sdfdsfdsfs, world.</h1>
</div>
);
}
}
当我更改 h1 标记中的文本时,会刷新浏览器。但是,当我更改 txt 属性时,什么也没有发生。我怎样才能让它工作?
【问题讨论】:
-
你的意思是当你在构造函数中更改
this.state = { ... }中的txt状态时没有任何反应?
标签: javascript reactjs react-native