DataArt interview question

how would you solve the problem with the optimization React application?