본문 바로가기
Develop/resolve issus & error

react-native-calendar-strip selectedDate 동작 안할 때

by arthur_noh 2022. 11. 30.

 

https://github.com/BugiDev/react-native-calendar-strip/issues/249

 

selectedDate prop change not updating state · Issue #249 · BugiDev/react-native-calendar-strip

Is. there any prop for value, as selectedDate is not working when changing its value?

github.com

 

사실 이건 이미 해결된 이슈이다.

<CalendarStrip
	...
    selectedDate={Your selectedDate}
/>

이렇게 하면 이제 내가 selectedDate 값을 변경해줄때마다 CalendarStrip의 press된 값이 변경되는데

Date 타입으로 전달하면 리랜더링을 안한다...

 

왜인지는 모른다. 몽키패치를 진행하려고 했는데 내부에서는 Moment 타입으로 변경해서 사용해서

혹시나...? 하고 Date 타입을 Moment 타입으로 변경하니까 쉽게 해결되었다.

<CalendarStrip
	...
    selectedDate={moment(insert your selectedDate)}
/>

 

라이브러리 자체가 moment 를 많이 사용하고 의존하고 있다보니 moment 타입 기준으로 만들어져서 그런듯?