본문으로 바로가기

rn 69.0 버전을 이상에서 발생되는 문제입니다.

 

 

1. 권장 수정

권장되는 해결 방법은 PropTypes에서 TypeScript와 같은 유형 시스템으로 전환하는 것입니다.

PropTypes를 계속 사용해야 하는 경우 수정 사항은 PropTypes를 사용하는 코드를 찾아 다음에서 가져오기를 전환하는 것입니다.

import { ViewPropTypes } from 'react-native';

=>아래 형태로 변환

import { ViewPropTypes } from 'deprecated-react-native-prop-types';

때로는 의존하는 라이브러리가 PropTypes를 사용하고 있을 수 있습니다. 이 경우 라이브러리에 이슈나 PR을 제출하거나 최신 버전으로 업데이트하는 것이 좋습니다. 극단적인 경우(예: 사용 중인 라이브러리가 유지 관리되지 않음) 라이브러리를 분기하거나 해당 라이브러리 자체 에 패치 패키지를 사용하여 업스트림에서 수정될 때까지 유형을 교체해야 할 수 있습니다 .

 

 

2. 권장수정을 하지못할 상황에서 처리.

그들은 내 경우 rn-polyfill-depricated-proptypes.js에서 원하는 이름으로 루트에 파일을 만들어야 하며 다음과 같이 맨 위에 있는 프로젝트의 index.js에 배치합니다.

이 후 생성 된 파일에 다음을 추가하십시오.

/**
*File: rn-polyfill-depricated-proptypes.js
**/

const StandardModule = require('react-native');
const dpProps = require('deprecated-react-native-prop-types');

const txtImputProx = new Proxy(StandardModule.TextInput, {
get(obj, prop) {
if (prop === 'propTypes') return dpProps.TextInputPropTypes;
return Reflect.get(...arguments);
},
});

Object.defineProperty(StandardModule, 'ColorPropType', {
configurable: true,
get() {
return dpProps.ColorPropType;
},
});

Object.defineProperty(StandardModule, 'EdgeInsetsPropType', {
configurable: true,
get() {
return dpProps.EdgeInsetsPropType;
},
});

Object.defineProperty(StandardModule, 'PointPropType', {
configurable: true,
get() {
return dpProps.PointPropType;
},
});

Object.defineProperty(StandardModule, 'ViewPropTypes', {
configurable: true,
get() {
return dpProps.ViewPropTypes;
},
});

Object.defineProperty(StandardModule, 'TextPropTypes', {
configurable: true,
get() {
return dpProps.TextPropTypes;
},
});

Object.defineProperty(StandardModule, 'TextInputPropTypes', {
configurable: true,
get() {
return dpProps.TextInputPropTypes;
},
});

Object.defineProperty(StandardModule, 'TextInput', {
configurable: true,
get() {
// return dpProps.TextInputPropTypes;
return txtImputProx;
},
});

 

 

참조 URL : https://github.com/facebook/react-native/issues/33734

 

Invariant Violation: ViewPropTypes has been removed from React Native. · Issue #33734 · facebook/react-native

Description Recently updated react to 18 version, and since that I'm not able to build my app. At first I've received "TypeError: dispatcher.useSyncExternalStore is not a function." and fixed by up...

github.com