Business
Jobs
  • About Us
  • Solutions
    • Job Postings
      Post your job and receive qualified candidates in 48h.
    • Candidate Assessments
      500+ technical and psychological tests, plus anti-fraud.
    • Headhunting
      Tailor-made executive search from start to finish.
    • Payroll + EOR
      Payroll dispersal and EOR across 15+ LATAM countries.
  • Pricing
  • Jobs

0

170
Views
Reaccionar: activa un evento o valor fuera del componente raíz

Alguien podría ayudarme con esta idea? No sé si era posible o debería usar alguna biblioteca o habilidad.

Componente (Esto es generalmente y común)

 import React, { useState } from "react"; export default function App() { const [anyVal, setAnyVal] = useState(0); return ( <div className="App"> <h1>Any Value: {anyVal}</h1> <button onClick={() => setAnyVal(anyVal + 1)}>Change value</button> </div> ); }

Conexión HTML + React Dom (Esto es generalmente y común)

 import { StrictMode } from "react"; import ReactDOM from "react-dom"; import App from "./App"; const rootElement = document.getElementById("root"); ReactDOM.render( <StrictMode> <App /> </StrictMode>, rootElement );

Aqui la parte que no se si sera posible

 <body> <div id="root" onanyvaluechanged="externalFn(v)"></div> <script> function externalFn(newValue) { alert("I've detected the change:" + newValue); } </script> </body>
about 4 years ago · Juan Pablo Isaza
1 answers
Answer question

0

Si está declarando la función en una etiqueta de script como esa, existe en el alcance de la ventana global, por lo que puede llamarla así desde su componente de reacción:

 window.externalFn('any value')
about 4 years ago · Juan Pablo Isaza Report
Answer question
Find remote jobs

Discover the new way to find a job!

Top jobs
Top job categories
Business
Post vacancy Pricing Sales
Legal
Terms and conditions Privacy policy
© 2026 PeakU Inc. All Rights Reserved.
Andres GPT
Show me some job opportunities
There's an error!