ReactJS: Pass Data from child to parent

ReactJS: Pass Data from child to parent

I just picked up React and can not solve this problem.

I just picked up React and can not solve this problem.

I have a search component that is embedded within the main app component. Within the search comp I make an API call with the input value from the search bar. But I do not know how I can get the Data back to the parent (where I currently use a hard coded state object similar to the data the API would return), to pass I to another component.

Basically: Get data from API within the Child, pass it to the parent and pass it down to 2 other childs

import React, {Component} from 'react';
import GroupItem from './components/GroupItem'
import SearchBar from './components/SearchBar'

class App extends Component {

state = { views: [ { name: 'Testname', description: 'testbeschreibung', status: 'ok' }, { name: 'Ein Anderer Titel', description: 'lorem ipsum', status: 'ok' } ], commands: [ { name: 'Wieder etwas', description: 'testbeschreibung', status: 'ok' } ], search : [] }

render() { return ( <div> <SearchBar/> <h2>Views </h2> { => (<GroupItem data={view} type={'view'} />))} <h2>Commands</h2> { => (<GroupItem data={command} type={'command'} />))} </div> ); } }

export default App;

import React, {Component} from 'react';

class SearchBar extends Component {

    let search =;
        .then((result) =&gt; {
            return result.json();
        }).then((jsonResult) =&gt; {

render() {
    return (
        &lt;div class="input-group mb-3" id="search"&gt;
            &lt;input type="text" class="form-control" ref="search" placeholder="URL" aria-label="URL" /&gt;
                &lt;div class="input-group-append"&gt;
                    &lt;button class="btn btn-outline-secondary" type="button" onClick={() =&gt; this.callApi()}&gt;Search&lt;/button&gt;


export default SearchBar;

Angular 9 Tutorial: Learn to Build a CRUD Angular App Quickly

What's new in Bootstrap 5 and when Bootstrap 5 release date?

Brave, Chrome, Firefox, Opera or Edge: Which is Better and Faster?

How to Build Progressive Web Apps (PWA) using Angular 9

What is new features in Javascript ES2020 ECMAScript 2020

ReactJS vs Angular vs Vue: Best Javascript Framework For Your Project

ReactJS vs Angular vs Vue: Best Javascript Framework For Your Project. This video covers the key differences between ReactJS, Angular and Vue with respect to the following: Use case, Performance, Data binding, Scripting language, Testing, Community support, Growth curve

What is JavaScript – All You Need To Know About JavaScript

In this article on what is JavaScript, we will learn the basic concepts of JavaScript.

JavaScript Tutorial: if-else Statement in JavaScript

This JavaScript tutorial is a step by step guide on JavaScript If Else Statements. Learn how to use If Else in javascript and also JavaScript If Else Statements. if-else Statement in JavaScript. JavaScript's conditional statements: if; if-else; nested-if; if-else-if. These statements allow you to control the flow of your program's execution based upon conditions known only during run time.