como puedo solucionar este problema, me sale un error que dice
Nothing was returned from render. This usually means a return statement is missing. Or, to render nothing, return null.
cuando quiero mostrar mi archivo JSON en mi pantalla de Lista (CurrenciesList.js) el código está aquí
import React from 'react' import { FlatList, View } from 'react-native' import RowItem from '../../components/RowItem' import currencies from '../../data/currencies.json' export default () => { <View> <FlatList data={currencies} renderItem={({item}) => { return <RowItem title={item}/> }} /> </View> }
RowItem es el componente reutilizable y solo pasa un parámetro de texto.
const RowItem = ({title, onPress}) => { return ( <TouchableOpacity onPress={onPress}> <Text style={styles.title}>{title}</Text> </TouchableOpacity> ) } export default RowItem
y mi archivo JSON (currencies.json) es así
[ "AUD", "BGN", "BRL", "CAD", "CHF", "CNY", "CZK", "etc.." ]
Tu función no devuelve nada.
cambio
export default () => { <View> </View> }
a:
export default () => { return <View> ... </View> }
o para
// no curly braces export default () => <View> ... </View>
Puedes probar esto,
import React from 'react' import { FlatList, View } from 'react-native' import RowItem from '../../components/RowItem' import currencies from '../../data/currencies.json' export default () => { return ( <View> <FlatList data={currencies} renderItem={({item}) => { return <RowItem title={item}/> }} /> </View> ); }