Not every good deed performed in public is ostentation. The question is why the deed is being done. Public charity may be intended to encourage others or permit transparent accountability; even a private deed can sometimes feed self-admiration. The word يُرَائِي identifies an intention to be seen and praised.
Example 1: Give assistance in ways that preserve the recipient's dignity rather than staging an unnecessary publicity image.
Example 2: If a good deed draws no praise, examine whether the desire for approval is distorting the intention.
The focus should be thoughtful self-correction, not suspicious accusations about other people's hearts.