-
Notifications
You must be signed in to change notification settings - Fork 0
/
Copy pathquestions.jsx
36 lines (31 loc) · 923 Bytes
/
questions.jsx
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
import React, { useState } from 'react';
const Question = ({ question, options, onNext }) => {
const [selectedOption, setSelectedOption] = useState('');
const handleOptionChange = (option) => {
setSelectedOption(option);
};
const handleNextClick = () => {
onNext(selectedOption);
};
return (
<div className="question-container">
<h2>{question}</h2>
<div className="options-container">
{options.map((option, index) => (
<label key={index}>
<input
type="radio"
name="option"
value={option}
checked={selectedOption === option}
onChange={() => handleOptionChange(option)}
/>
{option}
</label>
))}
</div>
<button onClick={handleNextClick}>Next</button>
</div>
);
};
export default Question;