Búsqueda de sitios web

typescript - React-Native Advertencia: Sobrescribiendo el atributo de estilo de la familia de fuentes del preprocesador


Estoy recibiendo la siguiente advertencia:

"Sobrescribiendo el atributo de estilo de la familia de fuentes en el preprocesador" aparece desde StyleSheet.js al ejecutar la aplicación en el simulador de iOS. Sin embargo, aún no lo he probado en Android.

App.tsx

import { StatusBar } from 'expo-status-bar';
import React from 'react';
import { StyleSheet, Text, View } from 'react-native';

export default function App() {
  return (
    <View style={styles.container}>
      <Text>Open up App.js to start working on your app!</Text>
      <StatusBar style="auto" />
    </View>
  );
}

const styles = StyleSheet.create({
  container: {
    flex: 1,
    backgroundColor: '#fff',
    alignItems: 'center',
    justifyContent: 'center',
  },
});

package.json

{
  "main": "index.js",
  "scripts": {
    "android": "expo run:android",
    "ios": "expo run:ios",
    "web": "expo start --web",
    "start": "react-native start"
  },
  "dependencies": {
    "expo": "~43.0.0",
    "expo-splash-screen": "~0.13.3",
    "expo-status-bar": "~1.1.0",
    "expo-updates": "~0.10.5",
    "react": "17.0.2",
    "react-dom": "17.0.1",
    "react-native": "0.66.1",
    "react-native-gesture-handler": "~1.10.2",
    "react-native-reanimated": "~2.2.0",
    "react-native-safe-area-context": "3.3.2",
    "react-native-screens": "~3.8.0",
    "react-native-web": "0.17.1"
  },
  "devDependencies": {
    "@babel/core": "^7.12.9",
    "@types/react": "^17.0.32",
    "@types/react-native": "^0.66.1",
    "typescript": "^4.4.4"
  },
  "private": true
}

¿Es un problema del paquete?

Respuesta #1

Esto viene directamente de Expo si tienes expo-font instalado.

Esta es la línea de código en node_modules/expo/build/Expo.fx.js que conduce a esa advertencia:

// If expo-font is installed and the style preprocessor is available, use it to parse fonts.
if (StyleSheet.setStyleAttributePreprocessor) {
  StyleSheet.setStyleAttributePreprocessor('fontFamily', Font.processFontFamily);

La línea de node_modules/react-native/Libraries/StyleSheet/StyleSheet.js que genera la advertencia:

if (__DEV__ && typeof value.process === 'function') {
  console.warn(`Overwriting ${property} style attribute preprocessor`);
}

Parece que lo mejor que se puede hacer por ahora sería ocultar la advertencia agregando las siguientes líneas al inicio de tu App.js o index.js:

import { LogBox } from 'react-native';
LogBox.ignoreLogs([
  "Overwriting fontFamily style attribute preprocessor"
]);

Respuesta #2

Pude solucionar este problema actualizando "react-native" a la versión "0.70.5".

Esto se puede hacer ejecutando:

npx expo install [email 

Artículos relacionados