[Solo Project -4] react-native 헤더에 버튼, 글 넣기

gun·2020년 8월 18일
0

solo-project

목록 보기
4/4

react-native 헤더에 버튼 넣는법

어플을 만들다 보면 헤더 부분에 버튼이나, 글을 넣어야 할때가 있을수 있다.

class Header_button extends Component {
  //react hooks를 사용할수 있음
	componentDidMount() {
		this.props.navigation.setOptions({
			headerRight: () => (
				<Button
					onPress={() => {
						return alert('게시글이 등록 되었습니다.');
					}}
					title="글등록"
				/>
			),
		});
	}
	render() {
		return (
			<View>
				<Text>기다려주세요</Text>
			</View>
		);
	}
}

0개의 댓글