##やりたいこと
Reactのアロー記法の中でcomponentDidMount()とか使いたい
###環境
- JavaScript ES6(ES6では使えないみたいなことないですよね...
- React.js
↓にcomponentDidMountとか入れたい
JavaScript
1//Sample.jsx 2 3import * as React from 'react'; 4 5const Sample = () => { 6 return ( 7 <div className='Sample'> 8 <h2>Sample</h2> 9 </div> 10 ); 11}; 12 13export default Sample; 14
JavaScript
1//Sample.jsx 2 3import * as React from 'react'; 4 5const Sample = () => { 6 componentDidMount() { //←エラーになる 7 console.log('hello'); 8 }, 9 return ( 10 <div className='Sample'> 11 <h2>Sample</h2> 12 </div> 13 ); 14}; 15 16export default Sample; 17
##試したこと
↓とかに書き換えてみたけどやはりundefind
componentDidMount: () => { console.log('hello'); }
回答1件
あなたの回答
tips
プレビュー