React Easy technical 1 views 1 min read

Can I use javascript urls in react16.9?

Peer-reviewed by HireXTech Technical Panel Updated for 2025/2026 hiring Editorial standards
Practise this track
Interviewer Expectations for this Question
01
Core Competency

Assesses fundamental understanding of React conventions, runtime behavior, and memory/performance considerations.

02
Evaluation Criteria

Hiring managers look for precision, avoidance of ambiguous jargon, and ability to explain trade-offs under real production conditions.

Comprehensive Model Answer Verified Solution

⚠️ DEPRECATED: As of React 19, javascript: URLs are no longer supported and may throw errors.

In React 16.9, javascript: URLs would log a warning in the console because URLs starting with javascript: are dangerous security vulnerabilities (XSS attacks).

     const companyProfile = {
       website: "javascript: alert('Your website is hacked')",
     };
     // This logged a warning in React 16.9
     // Now blocked or throws error in modern React
     <a href={companyProfile.website}>More details</a>;
     

Modern Best Practice:

  • Never use javascript: URLs
  • Use proper event handlers instead:
     const handleClick = (e) => {
       e.preventDefault();
       // Your logic here
     };
     
     <a href="#" onClick={handleClick}>More details</a>
     // Or better:
     <button onClick={handleClick}>More details</button>
     

## Disclaimer

The questions provided in this repository are the summary of frequently asked questions across numerous companies. We cannot guarantee that these questions will actually be asked during your interview process, nor should you focus on memorizing all of them. The primary purpose is for you to get a sense of what some companies might ask — do not get discouraged if you don't know the answer to all of them ⁠— that is ok!

Good luck with your interview 😊

---

Candidate Response Strategy & Interview Tips

  1. Start with a concise one-sentence summary: Deliver a direct, confident answer first before expanding into nuances.
  2. Demonstrate real-world trade-offs: Discuss where this approach excels and when you would avoid it in production systems.
  3. Discuss complexity & edge cases: Proactively explain time/space complexity or boundary conditions (null values, scale limits).
  4. Prepare for interviewer follow-ups: Technical hiring panels frequently probe deeper into concurrency, backward compatibility, or alternative libraries.
Related Topics & Skills
Spotted an error or have an alternative solution?