• Empleos
  • Sobre nosotros
  • profesionales
    • Inicio
    • Empleos
    • Cursos y retos
  • empresas
    • Inicio
    • Publicar vacante
    • Nuestro proceso
    • Precios
    • Evaluaciones
    • Nómina
    • Blog
    • Comercial
    • Calculadora de salario

0

164
Vistas
¿Hay alguna forma de agregar un elemento de imagen de imagen en reaccionar nativo sin recargar todas las demás imágenes que ha agregado?

Estoy tratando de hacer una aplicación de tic-tac-toe en reaccionar nativo y en lugar de cruces y o's normales, quería usar imágenes de gatos. Descubrí cómo agregar gatos, pero cada vez que agrego o elimino uno, todas las demás imágenes se recargan y se ven muy torpes. ¿Hay alguna solución para esto?

Aquí está el código

 function GameScreen() { const initialBoxVals = [0, 1, 2, 3, 4, 5, 6, 7, 8].map((idNum) => { return { id: idNum, checked: false, // eventually willl change to int of value 0 (initial state), 1 (checked by p1), 2 (checked by p3) }}) const boxStates = [0, 1, 2, 3, 4, 5, 6, 7, 8].map((i) => { return useState(initialBoxVals[i]) }) return ( <View style={styles.container}> <View style={styles.board}> <View style={styles.row}> <Box id={0} /> <Box id={1} /> <Box id={2} /> </View> <View style={styles.row}> <Box id={3} /> <Box id={4} /> <Box id={5} /> </View> <View style={styles.row} > <Box id={6} /> <Box id={7} /> <Box id={8} /> </View> </View> </View> ) function Box(props) { let [box, setBox] = boxStates[props.id] if (box.checked === true) { return ( <View style={styles.box} onTouchStart={() => setBox({...box, checked: !box.checked})}> <Image style={styles.image} source={require("../assets/grumpycat.png")} /> </View>) } else { return ( <View style={styles.box} onTouchStart={() => setBox({...box, checked: !box.checked})}> </View>) } } } export default GameScreen;```
almost 3 years ago · Juan Pablo Isaza
Responde la pregunta
Encuentra empleos remotos

¡Descubre la nueva forma de encontrar empleo!

Top de empleos
Top categorías de empleo
Empresas
Publicar vacante Precios Nuestro proceso Comercial
Legal
Términos y condiciones Política de privacidad
© 2025 PeakU Inc. All Rights Reserved.

Andres GPT

Recomiéndame algunas ofertas
Necesito ayuda