저번 블로깅에서 언급했듯이 navigation을 통해 데이터를 전달 받을 수 없어서 골머리를 앓는 상황을 겪었다.
이것은 같이 작업을 하는 팀원이 해결해줬다. 결국 root가 되는 component에서 props.route.params를 해당 component로 보내줘야 가능한 일이었다.
basicInfoScreen.js
const BasicInfoScreen = (props) => {
const styles = StyleSheet.create({
container: {
backgroundColor: "#f7f7f7",
height: hp("100%"),
},
});
return (
<SafeAreaView style={styles.container}>
<NameInput navigation={props.navigation} info={props.route.params} />
</SafeAreaView>
);
};
nameInput.js
const NameInput = ({ navigation, info }) => {
console.log(info)
...
}
데이터 전달받기 OK
이렇게 해서 페이지가 넘어가면서 하나의 데이터로 합쳐주고 그 합쳐준 데이터를 axios를 통해 회원가입 요청을 진행했고 회원가입에 성공하는 로직이었다. 이 로직은 결국 엄청 비효율적인 로직이겠지만 당장에는 이것 밖에 생각나지 않아서 이렇게 진행했다. 좀더 코드를 효율적으로 만들고 싶은데 아직 내공이 부족하다. 더 열심히 코딩을 하자.