Empresas
Empleos
  • Sobre nosotros
  • Soluciones
    • Publicación de vacantes
      Publica tu vacante y recibe candidatos calificados en 48h.
    • Evaluación de candidatos
      500+ pruebas técnicas y psicológicas, más anti-fraude.
    • Headhunting
      Búsqueda ejecutiva a la medida de principio a fin.
    • Nómina + EOR
      Dispersión de nómina y EOR en más de 15 países de LATAM.
  • Precios
  • Empleos

0

405
Vistas
render-error-text-strings-must-be-rendered-within-a-text-component

Problem: I am displaying all the BOOKS imgs using Flatlist that is stored in a google URL. I am using expo. When I open the application in a browser with expo it works. But when I run it on my phone it shows me an error as given below.

Error: Render Error : Text strings must be rendered within a Component here is the code:

import React, { Component } from 'react';
import {
  Text,
  View,
  Image,
  TextInput,
  FlatList,
  SectionList,
  StyleSheet,
  Button,
} from 'react-native';
class App extends React.Component {
  constructor() {
    super();
    this.state = {
      bookName: 'javascript',
    };
  }
  componentDidMount() {
    this.fetchApi();
  }
  fetchApi = async () => {
    let apiKey = 'AIzaSyDxoyfayTuP-hFon-b-nuzGjPdDAbpIPCY';
    const response = await fetch('https://www.googleapis.com/books/v1/volumes?q=' + this.state.bookName + '&key=' + apiKey + '&maxResults=5');
    const json = await response.json();
    this.setState({ data: json.items });
  };
  render() {
    return (
      <View style={styles.container}>
        <Text
          style={{
            fontFamily: 'Arial',
            fontSize: 20,
            fontWeight: 'bold',
            fontStyle: 'underline',
            color: 'yellow',
            marginTop: -300,
          }}>
          <Text>Random Users Data</Text>
        </Text>
        <View
          style={{
            width: 210,
            height: 50,
            marginTop: 50,
            justifyContent: 'center',
          }}>
          <TextInput
            style={{
              width: 210,
              height: 45,
              fontSize: 18,
              borderWidth: 3,
              borderRadius: 12,
              borderColor: 'royalblue',
              textAlign: 'center',
              backgroundColor: 'white',
            }}
            placeholder="Enter book name"
            onChangeText={(item) => this.setState.bookName(item)}
          />{' '}
        </View>
        <View>
          <FlatList
            data={this.state.data}
            keyExtractor={(x, i) => i}
            renderItem={({ item }) => (
              <View>
                <View style={{ marginTop: 200 }}>
                  <Image
                    style={{ width: 128, height: 204, margin: 10 }}
                    source={{ uri: item.volumeInfo.imageLinks.thumbnail }}
                  />
                </View>
              </View>
            )}
          />
        </View>
      </View>
    );
  }
}
const styles = StyleSheet.create({
  container: {
    flex: 1,
    justifyContent: 'center',
    alignItems: 'center',
    backgroundColor: 'black',
  },
});
export default App;
about 4 years ago · Juan Pablo Isaza
1 Respuestas
Responde la pregunta

0

Remove the {' '}. You probably accidentally added it while working on your project, but React is interpreting it as a space and complaining that text is found outside of a text component.

about 4 years ago · Juan Pablo Isaza Denunciar
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 Comercial
Legal
Términos y condiciones Política de privacidad
© 2026 PeakU Inc. All Rights Reserved.
Andres GPT
Recomiéndame algunas ofertas
Necesito ayuda