1

Is it possible to call a function of a child component on a direct way without creating a 'helper'-function on the top-level?

Can you explain me the right way to pass this problem?

export const AppComponent = () => {
    return (
        <ParentDiv>
            <ChildDiv />
        <ParentDiv />
    );
}

const ParentDiv = (props) => {
    return (<div>Parent{props.children}<button>do something...</button></div>);
}

const ChildDiv = (props) => {

    const submitButton = () => {
        console.log('do something...');
    }

    return (<div>Child</div>);
}
Steffen
  • 21
  • 3

0 Answers0