If the main visa holder's UK visa expires, your dependent visa also becomes invalid, which means you must apply to extend or switch your visa before your current visa expires, at the same time as your principal applicant's extension or switch application. You cannot remain in the UK as a dependent once the sponsor's visa is no longer valid, and you must leave the UK by the expiry date of your dependent visa.