Hi Trailblazer,
I came across a scenario where I need to refresh the whole page after we perform the logic from an inline LWC. After hitting hard I found below solutions.
eval("$A.get('e.force:refreshView').fire();");
Comments are closed.
Thanks so much for this one! any pointers on what exactly the above javascript function does?
Hi Ajay,
You can get the complete details from here:- https://developer.mozilla.org/en-US/docs/Web/JavaScript/Reference/Global_Objects/eval
This is Aura component, not LWC. Go back to reading books.
Thanks for your comment however this is working and the syntax is completely different. Why do not your post by your name instead of going anynomous.
I think you didnt understand what the author was saying. LWC doesnt have a force:refreshView event but aura does. We also know that we can host an LWC inside an aura. This point revolves around these 2 points. I think the author has read sufficient books and has significant experience to be able to present this ingenious idea. If you do not agree present your arguments rationally rather than posting unnecessarily rude comments.
The problem is that the first point mentions an Aura Component. The second point, by NOT mentioning an Aura Component, makes it sound like you don’t need one. If in fact it does, that should be clarified.
window.location.reload();
We can use above javascript code directly inside LWC to reload the page.
Yes, And this will reload the whole page not just the soft refresh
This works great! Thanks for the same!
Hi SFDC Panther, “eval is evil” we should never use it, it is an open door to XSS Scripting Attacks. Below is the link
https://medium.com/@eric_lum/the-dangerous-world-of-javascripts-eval-and-encoded-strings-96fd902af2bd.
Please let us know what do you think about it.