App.tsx
1import Title from './components/Title'; 2 3class App extends Component { 4 5 //Event handlerやstateを定義する場所 → OK 6 onClickHandler = () => { 7 let title = document.getElementById('versionCounter'); 8 let upgradeButton = document.getElementById('upgradeButton'); 9 upgradeButton.style.display = "none"; 10} 11 12//render()メソッド → OK 13render() { 14 15 //return → OK 16 return ( 17 <div className="App"> 18 <header className="App-header"> 19 <Title 20 title="Hello World 3.0" 21 titleStyle={{color: 'orange'}} 22 onClick={this.onClickHandler} 23 > 24 Hello World <span id="versionCounter" style={{borderBottom: '1px solid orange'}}>3.0</span> 25 </Title> 26 </header> 27 </div> 28 ); 29} 30} 31export default App;
Title.js
1import React from 'react'; 2 3type Props = { 4 title: string, 5 onClick: Function, 6 color: string 7} 8const Title : React.FC<Props> = (props) => { 9 return( 10 <div className = "titleSection"> 11 <h2 style={{props.titleStyle}} id= "versionStatement"> {props.children}</h2> 12 <p onClick = {props.onClick} id= "upgradeButton">Upgrade</p> 13 </div> 14 ); 15} 16 17export default Title;
下記の二つのエラーが解決できません
エラー内容
Type '{ children: (string | Element)[]; title: string; titleStyle: { color: string; }; onClick: () => void; }' is not assignable to type 'IntrinsicAttributes & Props & { children?: ReactNode; }'.
Property 'titleStyle' does not exist on type 'IntrinsicAttributes & Props & { children?: ReactNode; }'.
Type '{ children: (string | Element)[]; title: string; titleStyle: { color: string; }; onClick: () => void; }' is not assignable to type 'IntrinsicAttributes & Props & { children?: ReactNode; }'.
Property 'titleStyle' does not exist on type 'IntrinsicAttributes & Props & { children?: ReactNode; }'.ts(2322)
誰か教えてください
回答1件
あなたの回答
tips
プレビュー
バッドをするには、ログインかつ
こちらの条件を満たす必要があります。