Skip to content
Advertisement

Issue when trying to set one of div as selected in React JS

I have following code.

I’m trying to store a value in my state and every time the user goes to the previous step he can see what he has selected and after that he can change and move on to the next step.

At the first step, everything works good. For example, the user selects the second text and proceeds to the next step, and when he returns to this step, he sees that the second text has already been selected…

The problem is with the second step, I write all the same, but it doesn’t work for the second step. When I am clicking on one of the div’s in second step nothing was happened. There is no error. Please help me to figure out what’s the problem

Here is my code.

App file

JavaScript

first step package choose file

JavaScript

second step Term file

JavaScript

SelectCard file , in this file I am using onSelect

JavaScript

Please help me to understand how can I fix this problem in my code.

Thanks.

Advertisement

Answer

I edited your code.

Your issue in props that you passed.

before: setTerm={setTerm} , now: setSelected={setTerm}

https://codesandbox.io/s/little-leftpad-3owuu

Advertisement