1

I want to reload my ReactJS Page without refreshing it! There will be 'reload icon' in the page if some person click it then it should not Reload the page it should be single Page only!

Don't tell window.location.reload();

0

2 Answers 2

1

consider conditionally early returning the Redirect component : https://reactrouter.com/web/api/Redirect

so on your button click; setReload(true);

in your page component:

// before your regular return
if(reload) return <Redirect to={window.location.pathname} />;
Sign up to request clarification or add additional context in comments.

Comments

0

If your component is a class component you can use this code below in the click function. this.forceUpdate().

if your component is a functional one you can follow this answer

Comments

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service and acknowledge you have read our privacy policy.

Start asking to get answers

Find the answer to your question by asking.

Ask question

Explore related questions

See similar questions with these tags.