IT/React.js

[React] React does not recognize the `computedMatch` prop on a DOM element

월공 2022. 4. 12. 09:56
728x90
300x250

React 오늘의 오류

index.js:1 Warning: React does not recognize the `computedMatch` prop on a DOM element. If you intentionally want it to appear in the DOM as a custom attribute, spell it as lowercase `computedmatch` instead. If you accidentally passed it from a parent component, remove it from the DOM element.

 

원인

 

App.js 파일 내부에 Switch 문이 있는데 그 안에서 Route, Redirect 이외에 다른 Container 문을 써서 오류 표출

 

해결

 

Switch 문 바깥으로 빼고 로그인 했을때에 보여줘야 되는 화면이라 아래와 같이 진행하려했는데

{authenticated === false ? <></> :
          <>
            여기 안에서 보여주기           
          </>
        }

새로고침하면 무조건 메인으로 강제 어그로 끌리는 문제가 있어서

Switch 문 안에다가 다시 넣고 Fragment 태그로 감싸주니 에러도 뜨지않고 새로고침 했을때도 해당 위치 그대로 잘 갖고있었다.

 

 

근데 switch 문 안에 Route, Redirect 만 써야된다는 말이 있어서 이건 좀 더 찾아봐야할듯하고 ,

에러도 안뜨고 딱히 별 문제 없어보이는데, 혹시나 쓰다가 이상한 점 있으면 내용 수정할 예정입니다.

 

 

728x90
300x250