#typescript #react-native #jestjs #ts-jest
Вопрос:
Похоже, я, возможно, неправильно настроил что-то здесь, где собственные компоненты react помечаются как неродные компоненты из-за оболочки, но ясно, что компоненты уже имеют заглавную букву. Что здесь происходит?
console.error Warning: The tag lt;Textgt; is unrecognized in this browser. If you meant to render a React component, start its name with an uppercase letter. at Text at Component (/Project/node_modules/react-native/jest/mockComponent.js:28:18) at View at Component (/Project/node_modules/react-native/jest/mockComponent.js:28:18) at Index (/Project/pages/index.tsx:17:18) at printWarning (node_modules/react-dom/cjs/react-dom.development.js:67:30) at error (node_modules/react-dom/cjs/react-dom.development.js:43:5) at createElement (node_modules/react-dom/cjs/react-dom.development.js:9027:9) at createInstance (node_modules/react-dom/cjs/react-dom.development.js:10192:20) at completeWork (node_modules/react-dom/cjs/react-dom.development.js:19464:28) at completeUnitOfWork (node_modules/react-dom/cjs/react-dom.development.js:22812:16) at performUnitOfWork (node_modules/react-dom/cjs/react-dom.development.js:22787:5)
Ответ №1:
react-dom 17.0.1.патч
diff --git a/node_modules/react-dom/cjs/react-dom.development.js b/node_modules/react-dom/cjs/react-dom.development.js index d51615a..42b7495 100644 --- a/node_modules/react-dom/cjs/react-dom.development.js b/node_modules/react-dom/cjs/react-dom.development.js @@ -2722,9 2722,11 @@ function assertValidProps(tag, props) { } function isCustomComponent(tagName, props) { - if (tagName.indexOf('-') === -1) { - return typeof props.is === 'string'; - } // Added to suppress this warning here // https://stackoverflow.com/questions/70194105/text-is-unrecognized-in-this-browser-if-you-meant-to-render-a-react-component // Is seemed to be here because it's how web-component inherit, but it's not necessary // https://developer.mozilla.org/en-US/docs/Web/HTML/Global_attributes#attr-is // Accounts for custom components all having dashes // https://www.w3.org/2001/tag/doc/webcomponents-design-guidelines/#other-considerations if (tagName.indexOf('-') !== -1) return true; // accounts for components having upper case letters if (tagName == tagName.toLowerCase()) return false; switch (tagName) { // These are reserved SVG and MathML elements.