reactjs - Sending event handlers as props into a React component using TypeScript -


i have following code react component. what's right way declare 2 onclick handlers passed component?

interface loginformprops {     loginclicked: ???? <--- onclick handler signature     cancelclicked: ???? <--- onclick handler signature }  class loginform extends react.component<loginformprops, {}> {     render() {         <form>             <button onclick={loginclicked}>                 login             </button>             <button onclick={cancelclicked}>                 cancel             </button>         </form>     } } 

i typically use:

interface iloginformprops {     loginclicked: (ev) => void;     // } 

but if want strict typing:

interface iloginformprops {     loginclicked: (ev: react.mouseevent<htmlbuttonelement>) => void;     // } 

Comments

Popular posts from this blog

Is there a better way to structure post methods in Class Based Views -

reflection - How to access the object-members of an object declaration in kotlin -

php - Doctrine Query Builder Error on Join: [Syntax Error] line 0, col 87: Error: Expected Literal, got 'JOIN' -