I want to open another component which is in my example <HomePage />
when user fills a login form and clicks the submit button. I searched out and i got too many ways but not sure why none worked with me. Is there just a simple way to achieve this with React Hooks?
Login Component
const submit_login = () =>{
//code to open <HomePage /> Component
}
<form>
<div>
<input type="text" placeholder="username"/>
</div>
<div>
<input type="password" class="form-control" placeholder="password"/>
</div>
<div>
<input type="submit" onClick={submit_login} value="Login"/>
</div>
</form>
This is a very simple scenario, I believe this should be very easy to implement.
I tried router
switch
, hashrouter
, useHistory
, hookrouter
but all these didn't worked. some of the solutions i found was not updated since i am using latest version of ReactJS.