• Jobs
  • About Us
  • professionals
    • Home
    • Jobs
    • Courses and challenges
  • business
    • Home
    • Post vacancy
    • Our process
    • Pricing
    • Assessments
    • Payroll
    • Blog
    • Sales
    • Salary Calculator

0

165
Views
¿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;```
about 3 years ago · Juan Pablo Isaza
Answer question
Find remote jobs

Discover the new way to find a job!

Top jobs
Top job categories
Business
Post vacancy Pricing Our process Sales
Legal
Terms and conditions Privacy policy
© 2025 PeakU Inc. All Rights Reserved.

Andres GPT

Recommend me some offers
I have an error