Craig-Creeger / react-likert-scale

A React component that renders a Likert scale. It is responsive and accessible.
Creative Commons Zero v1.0 Universal
8 stars 6 forks source link

Fetch your choice and write it on the screen #13

Closed JonasWalsted closed 3 years ago

JonasWalsted commented 3 years ago

Hey First of all, thanks for the great package! Is it possible to write the answer as text on the screen, and how do you do this? For example, if the user chooses Poor, the code will write beneath the scale: "you have chosen Poor." Furthermore, I would like to make the text change, so if the user changes the answer from poor to Good, the text should also do this.

Craig-Creeger commented 3 years ago

Yes, you can do that. I have some example code you can take a look at: https://codepen.io/craig-creeger/pen/WNGaJxe Click on any of those radio buttons and you will see the text appear below the component.

Take a look at lines 20–30 in the Javascript pane. That set of code is the callback function that renders the text, such as "You have chosen Poor".

Line 58 is where that callback function gets passed into the Likert component.

Good luck!