score:0
write one function that does two things.
starttexthandler(e) {
// etc
},
dosomethingelse(e) {
// etc
},
starttexthandleranddosomethingelse(e) {
this.starttexthandler(e);
this.dosomethingelse(e);
}
....
onclick={this.starttexthandleranddosomethingelse}
score:0
try this:
<button onclick={()=> { this.starttexthandler(); this.secondaction(); } } text="start the test" />
score:0
you can pass an anonomus function:
<button
onclick={(event) => {
this.starttexthandler(event);
this.secondmethod(eventorwhatever)
}}
text="start the test"
/>
or a named function:
<button
onclick={this.handleclick}
text="start the test"
/>
handleclick = (event) => {
this.starttexthandler(event);
this.secondmethod(eventorwhatever);
}
btw: named function give you a better stacktrace too when debugging
score:1
you could create a function that includes both events:
<button onclick={this.calltwofuncs} text="start the test" />
<script>
function calltwofuncs() {
this.starttexthandler();
this.sendalert();
}
...
</script>
Source: stackoverflow.com
Related Query
- How do I have 2 onClick action on javascript?
- how should I build onClick action in my react component + Redux
- How can I refactor by moving files in a JavaScript project and have references update automatically?
- .React material Botton outline have black border-color onclick . But I haven't set it. How do I remove it?
- how to combine the objective arrays have the save same key in javascript
- How to test redux action by onClick with enzyme
- I have a div with a onClick handler and also buttons inside with onClick events. How do I prevent the buttons from firing the div onclick?
- How does a react action have access to dispatch?
- (react,antd,card) How can I block the onclick function from action buttons with antd card component?
- How to compare each elements in an Array and group the ones that have same data (in my case date) ? JavaScript
- With JavaScript + React, how to have a string evaluate inline?
- How to have two Secondary Actions in react material, One on left corner and one on right without affecting the behaviour of secondary action
- How to have button's onClick override as={Link} to={} (anchor tag)?
- How to find out if element in react have onClick event using dom
- How to compare if, 2 separate Objects/Array have one same element and concat 2 objects into one array, if there is matching element? Javascript
- How can I unit test onClick if it not have an mouse click event?
- I want to send the data from a request form to a database in the MySQL workbench from a javascript file in a ReactJs project, but I have no idea how
- How can I pass the index from javascript map function to the onclick function?
- I have two action need to pass in to my onClick button on react.js. But When I do, I fail to get it? is it any solution to solve it?
- How to set condition for onclick validation javascript
- How to loop through and display buttons that have an onClick and pass a different variable to another function?
- How can I have an onclick event in the DataGrid for any Column | React
- How to post data when you have javascript object using multipart/form-data content-type
- How to pass string value in onClick event listener in Javascript as we do it in onclick event listener in html
- How to have multiple onClick events on a button wrapped in a GraphQL mutation component in React
- How can I move to a different Page using onClick props of Material UI table action in React?
- How to test action have dispatched in pre render page on next js
- How can i target specific button's styling with onClick function if i have the same onClick function attached to multiple buttons?
- How to find if one of the items have completed property with value false from an array of objects using javascript and react?
- How to dispatch an action onClick in react redux?
More Query from same tag
- Test multiple React component state changes using Test Renderer
- Drag and Drop API with React not dropping or returning id
- Making an api call inside a function causing the browser to freeze in react (typescript)
- How do I add Material-UI to a JSFiddle project
- Failed to compile ./src/App.js Module not found: Can't resolve 'firebase'
- Javascript difficulty consuming promise values even after using await
- React onclick handler for checkbox group
- Flow: How to type an object with variable number of keys?
- How to test action props from ReactiveDict inside React component with Enzyme
- How dispatch is accessible in redux middleware?
- SSO react-google-login with google on react app using a react component
- timezones with moment Js
- How to aligment nodes with highcharts
- How can I convert string into an imported alias in React?
- TypeError: statevalue is undefined
- Download a file which is saved in your project - javascript react
- Event Not Firing, Issues Communicating Between React Components
- Prevent React table from scrolling to top on update
- What is the simplest way to have form input set function variable in React JS?
- React.useContext and Minified React error #321;
- Extract class name with styled-components
- create-react-app throws error: "Missing dependencies in package.json"
- React - Using a for-loop inside JSX
- How can I merge 2 modals into 1 using components with React / Redux?
- Perform a get request from a service worker based from Angular
- How to remove React-bootstrap popover onClick?
- How to redraw text rendered using SVGRenderer in Highcharts React?
- How do I change the background dynamically?
- semantic-ui-react Sticky advertisement (ad follows as scrolling)
- Clear a list of checkboxes in React