Business
Jobs
  • About Us
  • Solutions
    • Job Postings
      Post your job and receive qualified candidates in 48h.
    • Candidate Assessments
      500+ technical and psychological tests, plus anti-fraud.
    • Headhunting
      Tailor-made executive search from start to finish.
    • Payroll + EOR
      Payroll dispersal and EOR across 15+ LATAM countries.
  • Pricing
  • Jobs

0

103
Views
Component inside renderList in a FlastItem remounting after calling setState

I'm passing a component to the renderItem. Inside the component I have a state and i make a call to the api that will update this state with the response.

But what is happening is, it renders loading... then it actually shows what the api returned, goes back to showing loading and then goes back to showing what the api returned.

For example: if the searchDescriptionById function returns description 1, what is rendering on the screen is: loading... -> description 1 -> loading... -> description 1

as if at the first setState the component is remounting


const Component= ({ item }) => {
      const [description, setDescription] = useState('loading...');
      useEffect(() => {
        searchDescriptionById(item.id).then(res => {
          setDescricao(res);
        })
      }, [])
      return (
          <TouchableOpacity style={{ flex: 1 }}>
            <Textbold>{item.id}</Text>
            <Text>{description}</Text>
          </TouchableOpacity>
      )
  }

<FlatList
 data={data}
 contentContainerStyle={{ paddingBottom: 10 }}
 keyExtractor={item => item.id}
 renderItem={({item}) => <Component item={item}/>}
about 4 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 Sales
Legal
Terms and conditions Privacy policy
© 2026 PeakU Inc. All Rights Reserved.
Andres GPT
Show me some job opportunities
There's an error!