'Change Parent component based on Child props -> Preact/ React

I'm quite new to programming

In the example below, whenever child component renders null(...or in other words when getPosts() renders null), I want parent component div class to change from className={style.container} to className={style.container.minimized}.

What is the way to re-write this code to make this possible. Appreciate any help.

I have a Parent component like this

const Parent = () => {
    return (
        <div className={style.root}>
            <div>
                <div className={style.container}>
                    <Child />
                </div>
            </div>
        </div>
    );
};






My Child component is like this

const Child = () => {

     <div>
            {getPosts() ? (
                <div>
                    <p>Tomasz from {companyData.companyName}</p>
                    <p>{getPosts()}</p>
                </div>
            ) : null}
        </div>

}



Sources

This article follows the attribution requirements of Stack Overflow and is licensed under CC BY-SA 3.0.

Source: Stack Overflow

Solution Source