function Main(props){
return (
<div className='main_list'>
<p><a href='/' className='list' onClick={e=> {
e.preventDefault();
props.onChangeMode(e.target.className);
} }>목록 보기</a></p>
<p><a href='/' className ='write' onClick={e=> {
e.preventDefault();
props.onChangeMode(e.target.className);
} }>글쓰기</a></p>
</div>
)
}
const [mode, setMode] = useState('first_page')
const [id, setId] = useState(null);
let data_content = null;
if(mode === 'first_page'){
data_content = <Article body="오늘의 할 일을 적어보세요!"/>
} else if(mode === 'data_list'){
let title, body = null
for(let i = 0; i<topics.length; i++){
if(topics[i].id === id){
title = topics[i].title
body = topics[i].body
}
}
data_content = <Article title={title} body={body}/>
} else if(mode === 'write'){
data_content = <div>
<p><input type ="text" name = "title" placeholder='title'/></p>
<p><textarea name = "body" placeholder='body'/></p>
<p><input type ="submit" value="create"/></p>
</div>
}
아직 고쳐야할 부분
- 삭제시 ID 값 변경
- 디자인? 화면배치? 일단 깔끔하게만 해놓자!