Как я могу иметь 2 разных события нажатия кнопки и ListItem?
Я в основном заинтересован в событии нажатия кнопки без события ListItem.
CodeSandobox DEMO
import React from "react";
import ReactDOM from "react-dom";
import ListItem from "@material-ui/core/ListItem";
import ListItemText from "@material-ui/core/ListItemText";
function App() {
const handleButtonClick = () => {
console.log("button click");
};
const handleListItemClick = () => {
console.log("list click");
};
return (
<ListItem button onClick={() => handleListItemClick()}>
<button onClick={() => handleButtonClick()}>
get only the button click
</button>
<ListItemText primary="without the ListItem click event..." />
</ListItem>
);
}
const rootElement = document.getElementById("root");
ReactDOM.render(<App />, rootElement);