Objects are not valid as a React child

timeElapsed is an object, React doesn't know how to render this:

  <View style={[styles.timerContainer, this.borderColor('#ff6666')]}>
    {this.state.timeElapsed}
  </View>

Try changing this.state.timeElapsed for a string like for example:

  <View style={[styles.timerContainer, this.borderColor('#ff6666')]}>
    {this.state.timeElapsed.toString()}
  </View>

<Note note={
 <p>{(new Date(updated_at)).toString()}</p>
} />

In this case, Note is my child component and I had passed date as above and it worked for me.

Output Pass date to React Child


  • Short & simple is that use JSON.stringify()
  • because this.state.timeElapsed is the object. object not able to print in normal standered. Thus we need to render that object in JSON.stringify(). It converted into JSON form.

  • Try this, It's work for me

{JSON.stringify(this.state.timeElapsed)}