'Is there a way to imitate an event by a prop in react?
I want that if there is a prop "trial" in the element, than it would be considered like an "onClick" event:
import React from 'react';
export default function App () {
const trial = this.onClick = () => alert()
return (
<div
style={{background: `green`, height: 100, width: 100}}
trial={trial}
>
click
</div>
)
;
}
Is such a thing possible?
Sources
This article follows the attribution requirements of Stack Overflow and is licensed under CC BY-SA 3.0.
Source: Stack Overflow
| Solution | Source |
|---|
