React.jsを勉強しています。
こちらのサイトを参考に勉強をしているのですが、エラーが出てしまいます。
中身がからなのがいけないと言われているように見えますがどのように変更すれば良いのでしょうか?
他にもエラーが出ていたのでサイトのものを少し修正してあります。
typescript
1import * as React from "react"; 2import "./App.css"; 3 4export interface IProps {} 5export interface IState { 6 income: string; 7} 8const logo = require("./logo.svg"); 9 10class App extends React.Component<IProps, IState> { 11 constructor(props: IProps) { 12 super(props); 13 this.state = { 14 income: "" 15 }; 16 // メソッド内でthisを見るためのお約束 17 this.onChangeIncome = this.onChangeIncome.bind(this); 18 this.moneyYouWant = this.moneyYouWant.bind(this); 19 } 20 21 onChangeIncome(e: React.FormEvent<HTMLInputElement>) { 22 this.setState({ income: e.currentTarget.value }); 23 } 24 25 moneyYouWant(money: number): string { 26 if (money === NaN || money <= 0) { 27 return ""; 28 } 29 return `${money * 10000000}兆円欲しい`; 30 } 31 32 render() { 33 return ( 34 <div className="App"> 35 <div className="App-header"> 36 <img src={logo} className="App-logo" alt="logo" /> 37 <h2>Welcome to React</h2> 38 </div> 39 <p className="App-intro"> 40 <label> 41 現在の年収{" "} 42 <input 43 type="text" 44 value={this.state.income} 45 onChange={this.onChangeIncome} 46 />万円 47 </label> 48 </p> 49 <p className="Money">{this.moneyYouWant(Number(this.state.income))}</p> 50 </div> 51 ); 52 } 53} 54 55export default App;
js
1(4,18): An empty interface is equivalent to `{}`.
最新のコード
typescript
1import * as React from "react"; 2import "./App.css"; 3 4//export interface IProps {} 5export interface IState { 6 income: string; 7} 8const logo = require("./logo.svg"); 9 10class App extends React.Component<{}, IState> { 11 constructor(props) { 12 super(props); 13 this.state = { 14 income: "" 15 }; 16 // メソッド内でthisを見るためのお約束 17 this.onChangeIncome = this.onChangeIncome.bind(this); 18 this.moneyYouWant = this.moneyYouWant.bind(this); 19 } 20
回答2件
あなたの回答
tips
プレビュー
バッドをするには、ログインかつ
こちらの条件を満たす必要があります。
2018/07/20 07:05 編集
2018/07/20 06:51
2018/07/20 06:58 編集
2018/07/20 07:04
2018/07/20 07:07
2018/07/20 07:08
2018/07/20 07:18
2018/07/20 07:21 編集
2018/07/20 07:28
2018/07/20 07:31
2018/07/20 07:35
2018/07/20 07:52
2018/07/20 08:02
2018/07/20 08:02
2018/07/20 08:04
2018/07/20 08:14
2018/07/20 08:18
2018/07/20 08:41