React@16.9 block `javascript:void(0);`
See original GitHub issue<a href="javascript:void(0);"></a>
Warning: A future version of React will block javascript: URLs as a security precaution. Use event handlers instead if you can. If you need to generate unsafe HTML try using dangerouslySetInnerHTML instead. React was passed “javascript:void(0);”.
react@16.9
Issue Analytics
- State:
- Created 4 years ago
- Comments:13 (3 by maintainers)
Top Results From Across the Web
React 16.9.0 "javascript:;" href alternative? - Stack Overflow
After updating to React 16.9.0 I'm getting big warnings like this: Warning: A future version of React will block javascript: URLs as a...
Read more >[Solved]-React 16.9.0 "javascript:;" href alternative?-Reactjs
So probably one could replace a href="javascript:void(0)" with AHrefJavascript across the project and then just add an import for the component everywhere.
Read more >What does javascript:void(0) mean? - GeeksforGeeks
It is often used when inserting an expression in a web page might produce some unwanted effect. To remove this effect, “javascript:void(0)” is ......
Read more >CoffeeScript
CoffeeScript is a little language that compiles into JavaScript. ... var error; alert((function() { try { return nonexistent / void 0; } catch...
Read more >What does javascript:void(0) mean? - STechies
To prevent the default behaviour of a web page, you might face problems while using javascript: void(0) to React. For this JavaScript library,...
Read more >
Top Related Medium Post
No results found
Top Related StackOverflow Question
No results found
Troubleshoot Live Code
Lightrun enables developers to add logs, metrics and snapshots to live code - no restarts or redeploys required.
Start Free
Top Related Reddit Thread
No results found
Top Related Hackernoon Post
No results found
Top Related Tweet
No results found
Top Related Dev.to Post
No results found
Top Related Hashnode Post
No results found
You could use
<button type="button" onClick={}>...</button>, the added benefit here is that the role of the element is better communicated to screen reader users using your feature 👍We encountered this issue too. The following didn’t work for us as it would refresh the page:
What did work was using the NavLink inside the react-router-dom library. We were already using it and it perfectly mimics the javascript:void(0) behaviour (but without the warning!).
<NavLink to="#" onClick={e => e.preventDefault()}>