Devaluing your currency doesn't automatically fix your trade deficit
Economists Alfred Marshall and Abba Lerner showed that making your exports cheaper abroad only improves your trade balance if demand reacts enough, specifically, if the combined price-elasticities of exports and imports add up to more than one. Right after a devaluation, demand usually hasn't adjusted, so the trade balance often gets worse before it gets better, a pattern called the J-curve. Studies find the condition holds in some economies over the long run and fails in others.