我在地图中有这两个单选按钮,我想单独更改它们的状态,现在的行为是当我切换一个地图中的所有单选按钮时。
import React from "react";
import "./styles.css";
const questionario = () => {
const [checked, setChecked] = useState("yes");
return (
<>
{questions.map((data, i) => (
<Text style={styles.text}>
{i + 1} - {data.question}{" "}
</Text>
<Text style={{ color: "#fff", fontSize: 18, marginLeft: 10 }}>
{data.atividades}
</Text>
<View style={styles.radioButtonContainer}>
<RadioButton
value="yes"
color="#fff"
uncheckedColor="#fff"
status={checked === "yes" ? "checked" : "unchecked"}
onPress={e => setChecked("yes")}
/>
<Text style={styles.radioText}>Sim </Text>
</View>
<View style={styles.radioButtonContainer}>
<RadioButton
value="no"
color="#fff"
uncheckedColor="#fff"
status={checked === "no" ? "checked" : "unchecked"}
onPress={() => setChecked("no")}
/>
<Text style={styles.radioText}>Não </Text>
</View>
))}
</>
);
};
export default function App() {
return (
<div className="App">
<h1>Hello CodeSandbox</h1>
<h2>Start editing to see some magic happen!</h2>
</div>
);
}