Issue with onExited method in material-ui component not functioning as expected

I'm attempting to implement the onExited method (Material-UI v1.0.0-beta.41) in my React.js code like this:

fireOnExit=()=>{
  alert("Exited");
 }

 <button label="Cancel" onClick={this.handleClose} onExited{()=>this.fireOnExit()}/>

Unfortunately, it's not functioning as expected. Do you have any suggestions? Thanks!

Answer №1

Give this a shot:

class Demo extends React.Component {
  handleExit = (event) => {
    event.preventDefault();
    console.log("Exited")
  }
  render() {
    return <button label= "Cancel" onClick= { this.handleClose } onExited{this.handleExit} />
  }
}

Similar questions

If you have not found the answer to your question or you are interested in this topic, then look at other similar questions below or use the search

The alignment of the first and second steps in Intro.js and Intro.js-react is off

There seems to be an issue here. Upon reloading, the initial step and pop-up appear in the upper left corner instead of the center, which is not what I anticipated based on the Intro.js official documentation. https://i.stack.imgur.com/ICiGt.png Further ...

Do we still require the material-ui custom touch event? It seems to cause many issues

It has come to my attention that material-ui still relies on a package that appears to be incompatible with new React updates from Facebook. There seems to be some frustration over this issue, making it challenging to keep up with React advancements. Is th ...

Add a new key-value pair to the mock data by clicking on it

Hey there! I'm currently tackling a task that involves toggling the value of a boolean and then appending a new key-value pair on click. I've been attempting to use the . operator to add the new key-value pair, but it keeps throwing an error. In ...

Utilizing Google's ReCaptcha v3 with Next.js

Trying to integrate react-google-recaptcha-v3 into my React application using version 16.13.1 & Next version 9.4.4. Encountering an issue at const result = await executeRecaptcha("homepage") in pages/index.js. console.log(process.env.GOOGLE ...

We encountered an error: The module 'history' cannot be located in the specified directory: '/Users/aronfischer/the_odin_project/passport-starter/src'

I keep encountering this issue: Module not found: Can't resolve 'history' in '/Users/aronfischer/the_odin_project/passport-starter/src' whenever I run npm start and I'm struggling to identify the cause. I believe my file str ...

When working with JSX in Next.js, it is important to remember that expressions must be

I am currently working with Next.js and React.js to develop this project. I have been following a tutorial on YouTube, where the instructor successfully implemented the same code. However, when I try to run it, it is not working as expected. Can anyone pr ...

The implementation of race in React Redux Saga is proving to have negligible impact

I have implemented the following saga effect: function* loginSaga() { const logoutTimeoutCreationDate: string | null = yield localStorage.getItem('logoutTimeoutCreationDate'); let logoutTimeout: number; if (!logoutTimeoutCreationDate || + ...

What is the best way to display a loading indicator on a Next.js page?

At times in Next.js, there can be a delay in loading a page without any visual cues to show that the page is changing after triggering a <Link /> click or using router.push. Imagine being on a dictionary website looking at a word definition. You the ...

Authentication Error: CSRF cookie not detected - Please log in again to access the /login/ page using REACT and DJANGO

After successfully developing the frontend using React and backend with Django, everything was functioning flawlessly on localhost. However, upon deploying the frontend on Heroku and attempting a POST request to log in (with the backend still running on lo ...

Design buttons that are generated dynamically to match the style

I have a challenge in styling dynamically generated buttons. I've developed a component responsible for generating these dynamic buttons. const TIMER_PRESETS: Record<string, number> = { FIFTHTEENSEC: 15, THIRTYSEC: 30, FORTYFIVESEC: 45, ...

Tips for preventing the unmounting of child components while utilizing JSX's map function

This is a condensed version of a question I previously asked. Hopefully, it's clearer and more comprehensible. Here is a simple application with 3 input fields that accept numbers (disregard the ability to enter non-numbers). The app calculates the s ...

Having difficulty entering text in the modal text box and updating it with a new state

Within my render method, I am utilizing the following model: { showEditModal && <Modal toggleModal={this.togglePageModal} pageModal={true}> <h2 style={{ textAlign: "center", width: "100%" }}> ...

Can anyone guide me on troubleshooting the firebase import error in order to resolve it? The error message I am encountering is "Module not found: Error:

When attempting to import the 'auth' module from my 'firebase.js' file, I encountered an error. I used the code import {auth} from "./firebase", which resulted in the following error message: Error: Unable to locate module &a ...

Utilize the get method to showcase data in a material UI table for a React application

Just starting out with React. Managed to create a table component with hard-coded data. However, I now have all the data stored in table.json. Can someone guide me on how to fetch values from table.json using an axios get request an ...

Enhancing React Native View and other component properties using styled-components

Utilizing styled-components for styling in my React Native app using Typescript has been effective. I recently crafted a StyledComponent to style a View component, but encountered an error when attempting to extend the ViewProps: The type '{ children: ...

Delete element from the array upon removal from the AutoComplete component

I am facing a challenge with the Material UI AutoComplete component in my project. The issue arises when I try to update the state of the associateList after clearing a TextField. Additionally, I would appreciate any guidance on how to handle removing an ...

React Dependency Conflict: Material-UI (Mui) Causing Issues of Incompatibility

While trying to install react dependencies using npm i in Netlify, it appears that there are some missing or unresolved libraries in material-ui. Could someone offer assistance in determining the correct versions? 1:48:24 PM: Failed during stage "Ins ...

What steps can be taken to ensure that when one <ListItem> component expands within a <List> component in React Material UI, all other <ListItem> components remain collapsible?

Our current application is utilizing the react material ui components for web page design. In a specific scenario, we are using the <List> material ui component, with some modifications based on our application's needs, as recommended in https:/ ...

Show a notification if there are any errors in the form upon submission using react-final-form

I am currently working with react-final-form and I'm trying to figure out how to display an alert when a user tries to submit a form with errors. I have created a function for the onSubmit event like so: onSubmit={event => { event.preventDefault ...

Alternatives to using wildcards in TypeScript

In my code, I have defined an interface called ColumnDef which consists of two methods: getValue that returns type C and getComponent which takes an input argument of type C. Everything is functioning properly as intended. interface ColumnDef<R, C> { ...