Button disappears on resize

Hi All,
I’m new to JUCE and I’m trying to work with a FlexBox.
I created a new GUI project and added a text button to the main component and I’m trying to use a FlexBox for the layout (obviously, I’ll add more controls later, it’s not just for the button :slight_smile: ).
It appears to work fine when the app starts but when I try to resize the window the button just disappears!
What am I missing?

Here is my code:

    setSize (600, 400);

    _saveButton.onClick = std::bind(&MainComponent::onSaveButtonClick, this);

void MainComponent::onSaveButtonClick()


void MainComponent::paint (Graphics& g)
    // (Our component is opaque, so we must completely fill the background with a solid colour)
    g.fillAll (getLookAndFeel().findColour (ResizableWindow::backgroundColourId));


void MainComponent::resized()
    // This is called when the MainComponent is resized.
    // If you add any child components, this is where you should
    // update their positions.
    auto r = getLocalBounds();

    FlexBox sidebar;
    sidebar.items.add( _saveButton );


You need to specify the FlexBox parameters.

see this constructor