저는 React를 처음 접했고 한 번의 클릭으로 다른 반응 구성 요소를 렌더링하고 싶습니다. 버튼이있는 ListModules 구성 요소가 있습니다. 이제 단추를 클릭하면 다른 구성 요소가 렌더링됩니다. 아래 코드를 작성했으며 모듈은 내 상태이며 백엔드의 가치가 있습니다.
const addTimeline = () => {
return <ColorsTimeline data={module} />
}
<button type="submit" class="btn btn-success" onClick={addTimeline}>DONE</button>
도와주세요 :)
이것은 작동합니다.
const[show,setShow]=useState(false);
return(
{show?<ColorsTimeline data={module} />:null}
<button type="submit" class="btn btn-success" onClick={()=>{setShow(true)}}>DONE</button>
)
이 기사는 인터넷에서 수집됩니다. 재 인쇄 할 때 출처를 알려주십시오.
침해가 발생한 경우 연락 주시기 바랍니다[email protected] 삭제
몇 마디 만하겠습니다