score:1
Accepted answer
Make sure to pass playerId
to onDelete
method
1st way
Since your onDelete function has a function inside function. Just call onDelete
and pass playerId
<Button onClick={onDelete(playerId)} color="primary" autoFocus>
Yes
</Button>
2st way
Rewrite onDelete
properly. There is no need to put fun inside a fun.
const onDelete = id => {
try {
Axios.delete('http://localhost:8000/service/player', id);
setDeleteDialog(false);
} catch (e) {
console.log(e);
}
}
Now just call provide an inline arrow function to onClick
<Button onClick={() => onDelete(playerId)} color="primary" autoFocus>
Yes
</Button>
score:0
<Dialog
open={open}
onClose={onClose}
onDelete={onDelete}
aria-labelledby="alert-dialog-title"
aria-describedby="alert-dialog-description"
>
Dialog component doesn't have prop onDelete
https://material-ui.com/api/dialog/
Source: stackoverflow.com
Related Query
- On click on delete throws error Unknown event handler property `onDelete`
- Warning: Unknown event handler property `onHeaderClick`. It will be ignored
- Material-ui: Warning: Unknown event handler property `onKeyboardFocus`. It will be ignored
- REACT - Unknown event handler property
- When .filter when dismiss event is called, it throws an error and doesn't work. It says cannot read the property 'filter' of undefined
- Event handler throws invalid hook call error
- Why the warning: Unknown event handler property `onSession` is displayed in React app?
- Warning: Unknown event handler property `onValueChange`. It will be ignored
- Jest error - Not implemented: navigation (except hash changes) when click event is triggered on an anchor element
- React Event Handler Button Click Not Working on First Click
- Removing chart on click event produces 'removeHoverStyle' of null error
- Retrieve value property of div in the click event
- Unable to navigate on click of a Link. Getting error "TypeError: Cannot read property 'push' of undefined"
- React KeyDown event handler in compnent - function error
- How to catch the error thrown inside event handler of a child component?
- React Typescript : MuiAccordion OnChange event handler type error
- JavaScript click event handler not fired in the code below
- React for table rows to bind (this) click event handler
- MobX throwing error when binding event handler in ObservableArray.map(..)
- onClick event handler called on load as opposed to on click
- Unable to delete list item in react. Error shows: Uncaught TypeError: Cannot read property 'remove' of undefined
- mapping object throws error "TypeError: Cannot read property 'state' of undefined"
- React function with onClick event throws "TypeError: Cannot read property 'handleDelete' of undefined" in console
- React file throws error Cannot read property 'style' of undefined only when I refresh the page
- Changing the react-leaflet layer url by mutating react state throws error -> TypeError: Cannot read property 'call' of undefined
- Shuffle Array click handler event help React
- Cannot read property map of unknown error
- The on click handler in React.js executes before the event happens. How can I stop that?
- Is there a way to disable the warnings "Invalid event handler property `onclick`" of React?
- Defining React-Redux dispatch as generic function property throws error with typescript 3.1.3
More Query from same tag
- State is not Reflecting after calling HandleCheck Method in React Product List Program
- React: Update Child Component Without Rerendering Parent
- NextJS: Reload iFrame from another component
- How to update the result on right side based on user input
- React update object value(quantity) for update db
- How can I dynamically change part of text inside a reactjs render?
- bind(): You are binding a component method to the component. React does this for you automatically?
- how do you mock a default exported object with jest per test?
- React router open page using URL
- How to send password reset email from django using django-rest-framework and React
- Zomato API not working - ReactJs
- React Bootstrap Modal Popup in Axios?
- Dynamic Material Icon - Too many re-renders
- Trying to fetch random words from API and displaying them
- navigate with react-router-dom v6 not working
- creating an array in the object
- Implementing a countdown timer in React with Hooks
- Using webpack to prepend variables for SCSS
- Typing a letter in the middle of a string takes the cursor back to the end - Material UI
- How can I prevent TypeError: Cannot read property 'map' of undefined when submitting empty form data?
- Creating react class with several components
- Data filtration React Highcharts
- How do I convert my codes to correct jsx format?
- How do I send multiple form inputs in a post request react
- .htaccess file is not recognized by Apache
- How to position columns at the left and data at the right of material UI table for React
- Unable to fetch the data from getAttribute on button call
- React setState doesn't update boolean variable
- concatenating fields in react.js method
- How to redirect to a page in React.js