I am using React Router to set up my contact page (which consists of multiple pages, nested router):
<Route path="/contact" element={<Contact />}>
<Route path="name" element={<ContactName />} />
<Route path="email" element={<ContactEmail />} />
<Route path="message" element={<ContactMessage />} />
</Route>
When I first go into my contact page, I have a button to move on to the ContactName page (so they can enter their name):
<a
href="/contact/name"
className="contact-icon-color contact-icon-link"
onClick={() => { setContactButton(false) }}>
</a>
When they click the button, I set the display property of the button link to none. This works like I intended. However, when it moves onto the ContactName page, the button reappears again. I understand that the boolean value contactButton is reset with the followoing line in my functional component:
const [contactButton, setContactButton] = useState(true);
I do not know how to overcome this. My questions are:
- Is there a better alternative way to remove the button or move onto the next page?
- If not, how would I store the latest value for contactButton so that the link does not reappear?
Thanks, please note that I am new to React.