〜うちに is used to refer to a period of time. The period of time is represented by the modifier in front of うちに. Often 〜うちに is used when taking advantage of an opportunity.
- When contrasting with another period of time, 〜うちは is used.
- How to use うちに & うちは ( = uchi ni & uchiwa) (maggiesensei.com)