我正在嘗試根據條件是否有兩個值來呈現 html div。
向導輸入將 responseType 變數更改為“textMessage”或“textToSpeech”。不確定我的條件是否正確...
const stepOne = () => {
const responseType = watch("responseType")
return (
<WizardInput
type="radio"
id="textMessage"
checked={upload?.responseType === "textMessage"}
tag={CustomInput}
onChange={({ target }) => {
handleInputChange(target);
}}
innerRef={register({
required: "Add your message silly goose"
})}
value="textMessage"
name="responseType"
errors={errors}
/>
<WizardInput
type="radio"
id="textToSpeech"
checked={upload?.responseType === "textToSpeech"}
tag={CustomInput}
onChange={({ target }) => {
handleInputChange(target);
}}
innerRef={register()}
value="textToSpeech"
name="responseType"
errors={errors}
/>
// trying to render this h5 if textMessage OR textToSpeech
{ responseType === "textMessage" || "textToSpeech" && (
<div>
<h5>This here</h5>
</div>
)}
)}
uj5u.com熱心網友回復:
您需要再次檢查相等性。
(responseType === "textMessage" || responseType === "textToSpeech") && (
<div>
<h5>This here</h5>
</div>
)
uj5u.com熱心網友回復:
嘗試
(responseType === "textMessage" || responseType === "textToSpeech") && (<div>...</div>)
轉載請註明出處,本文鏈接:https://www.uj5u.com/ruanti/460031.html
標籤:javascript 反应 反应挂钩形式
上一篇:如何檢查陣列中是否存在數字?
