'How to get the material ui Button component content value onclick

enter image description here

How can i get the value Add Property onClick?



Solution 1:[1]

Updated Answer

I guess then this is what you are looking for:

onClick={(event) => {
  console.log(event?.target?.textContent);
}

Original Answer

Do you have access to isLastStep? If yes, you could just use that to determine which strings is shown in the button like:

<Button
  type="submit"
  variant="contained"
  color="primary"
  className={classes.button}
  onClick={() => {
    console.log(isLastStep ? "Add Property" : "Next");
  }
>
  { isLastStep ? "Add Property" : "Next" }
</Button>

If this is not what you are looking for, can you please be more speficic providing a different example of what you want to do?

Sources

This article follows the attribution requirements of Stack Overflow and is licensed under CC BY-SA 3.0.

Source: Stack Overflow

Solution Source
Solution 1