react.jsを学び始めたのですが、下記のコードで、handleMouseOver()を実行しても、何も変化が起きず、
tanakaという文字列の表示が行われたまま変化がありません。
利用している教材のサンプルのコードでは動いているのですが、どなたかご教示いただけますと幸いです。
react.js
1import React, { Component } from 'react'; 2import Greeting from './greeting'; 3 4class App extends Component { 5 constructor(props){ 6 super(props); 7 this.state = { 8 name: 'tanaka', 9 }; 10 } 11 12 handleMouseOver(){ 13 this.setState({ name: 'Bob'}); 14 } 15 16 handleMouseOut(){ 17 this.setState({ name: 'mike'}); 18 } 19 20 render(){ 21 return ( 22 <div 23 onMuoseOver={() => this.handleMouseOver()} 24 onMuoseOut={() => this.handleMouseOver()} 25 > 26 <Greeting name = {this.state.name} /> 27 </div> 28 ); 29 } 30} 31 32export default App; 33
回答1件
あなたの回答
tips
プレビュー