How to Update Child Component State from Parent Component

May 08, 2021

Problem Statement

I have a parent component which loads some list categories. Based on the selection of this category, I want to show some data in a table. And, I have a table component which displays that data.

So, based on selectio, data on child component must change.


The solution is to maintain state in parent component, and pass the props to child component. And the child component, will read data from props.

Parent Component Example

import apiClient from '../../components/api/api_client'
import SimpleLayout from '../../components/layout/simple'
import React, { Component } from 'react'
import { Form } from 'react-bootstrap';
import EmailTable from '../../components/emailView/emailTable'

export default class Users extends Component {
  constructor(props) {
    this.state = {
      emails: []

  handleSelection = async (event) => {
      emails: await apiClient.getEmailsForList(

  render() {
    const emaillist = this.props.emaillist;
    return (
        <div className="row">
            <Form.Group controlId="exampleForm.SelectCustomSizeLg">
              <Form.Label>Email Lists</Form.Label>
              <Form.Control as="select" custom
                {emaillist &&, index) => {
                    <option key={index} value={}>{}</option>
              <EmailTable emails={this.state.emails} />

Child Component (EmailTable)

Now the child component will just render data from its props.

import React, { Component } from 'react'
import { Table } from 'react-bootstrap';

export default class EmailTable extends Component {
  render() {
    return (
      <Table striped bordered hover variant="dark">
          {, index) => {
              <tr key={index}>


Parent page

Child Component table

Hope it helps.

Similar Posts

Latest Posts