我的代码不工作,我的代码出了什么问题? 我正在try 创建一个简单的问答应用程序,我分享了下面的代码示例,在下面的示例中,我如何才能在默认情况下隐藏答案,并在单击按钮时显示答案? 多谢你们的支持.
import React, { useEffect, useState } from "react";
import {View, Text, StyleSheet, Button} from 'react-native'
const Testing = () =>{
const [showValue, setShowValue] = useState(false);
return (
<View style={{
backgroundColor: '#f1f1f1',justifyContent: 'center', alignItems: 'center',}}>
<Text>1. What is Lorem Ipsum?</Text>
<Text>
1. dummy
2. text
3. Ipsum
4. Lorem
</Text>
{showValue? <Text style={{color: 'green', margin: 10,}}>Answer: Lorem</Text> : null}
<Button title="Show Answer" onClick={() => setShowValue(!showValue)} />
</View>
);}
export default Testing;