SongMinQQ / I-want-to-leave

2024-2 캡스톤디자인 여행 플랫폼 "떠나볼래"
0 stars 0 forks source link

Warning: A props object containing a "key" prop is being spread into JSX #2

Closed SongMinQQ closed 1 month ago

SongMinQQ commented 1 month ago

마이페이지에 들어가면 해당 경고(에러) 발생

image

SongMinQQ commented 1 month ago

패치 파일 적용

diff --git a/src/TabBar.tsx b/src/TabBar.tsx
index e8d0b4c8dcbbe779fcd304f483d2d91c2d5e8dde..203adc927db153df3f8472d4ec67346e1cd7405b 100644
--- a/src/TabBar.tsx
+++ b/src/TabBar.tsx
@@ -364,8 +364,7 @@ export function TabBar<T extends Route>({

   const renderItem = React.useCallback(
     ({ item: route, index }: ListRenderItemInfo<T>) => {
-      const props: TabBarItemProps<T> & { key: string } = {
-        key: route.key,
+      const props: TabBarItemProps<T> = {
         position: position,
         route: route,
         navigationState: navigationState,
@@ -446,9 +445,9 @@ export function TabBar<T extends Route>({
         <>
           {gap > 0 && index > 0 ? <Separator width={gap} /> : null}
           {renderTabBarItem ? (
-            renderTabBarItem(props)
+            renderTabBarItem({key: route.key, ...props})
           ) : (
-            <TabBarItem {...props} />
+            <TabBarItem key={route.key} {...props} />
           )}
         </>
       );

node_modules/react-native-tab-view/src/TabBar.tsx의 367, 368 line 다음과 같이 수정

const props: TabBarItemProps<T> = {
//key: route.key, 이거 주석처리 하거나 삭제

renderItem 함수의 return문을 다음과 같이 수정

<>
       {gap > 0 && index > 0 ? <Separator width={gap} /> : null}
       {renderTabBarItem ? (
         renderTabBarItem({key: route.key, ...props})
       ) : (
         <TabBarItem key={route.key} {...props} />
       )}
</>