It's a bit complicated here, but ideally companies wanting noncompetes could be forced to pay the difference between what the worker would've earned if they stayed (+ some safety factor for a potential raise elsewhere, eg 20%) and what they earn now with a noncompete.
So if a worker earned 100k, with the safety factor for a raise that means 120k, and can only earn 50k due to a noncompete, the company would have to pay the difference of 70k to that worker if they wanted to keep the noncompete valid (for a limited amount of time). Company keeps their 'secrets', but has to pay for the secrecy.