How to make sure that the component is not redrawn? | Sololearn: Learn to code for FREE!
New course! Every coder should learn Generative AI!
Try a free lesson
+ 1

How to make sure that the component is not redrawn?

I need 2 conditions to be met: 1) When you click on the «Increase temperature by 1 degree» button, the temperature increased 2) The TempDisplay component should not be redrawn when you click on the «Increase by 10 seconds» button https://code.sololearn.com/WqNNZYOaONoQ/?ref=app https://code.sololearn.com/W5TL65B4BaQJ/?ref=app

5th Jul 2023, 2:40 PM
  - avatar
4 Answers
+ 4
I'm a bit confused by your codes. You want a button to do something, but you don't have any button in the codes. I believe you aren't closing all of your curly brackets {}, they need a pair 1x { and 1x }. You have a lot of "const" in there and they should only be used for variables which don't change values.
5th Jul 2023, 5:50 PM
Ausgrindtube
Ausgrindtube - avatar
+ 2
Can you post the task completely? Also, all of your code, including buttons.
6th Jul 2023, 12:57 PM
Ausgrindtube
Ausgrindtube - avatar
0
Yes, the buttons I have not written in this code, but the task is that after "1 usage new * const increaseTemp=" add code so that 1) When you click on the button "Increase the temperature by 1 degree" the temperature increases 2) TempDisplay component should not be redrawn when you click "Increase by 10 seconds
5th Jul 2023, 6:21 PM
  - avatar
0
As I understand it, it should be done through useMemo
5th Jul 2023, 6:36 PM
  - avatar