user1122
user1122

Reputation: 57

How can we show and error symbol (like '!') in case of an error in ReactJS?

I am using ReactJS + MaterialUI components. I want to highlight to the user and show '!' mark when there is an error in a tab. I am looking to put an error mark on the tab name so that the user can click to see more.

Is there any way to show this?

Upvotes: 0

Views: 97

Answers (1)

Michael
Michael

Reputation: 405

https://codesandbox.io/embed/material-demo-ioxsf?fontsize=14&hidenavigation=1&theme=dark

Add import ErrorIcon from "@material-ui/icons/Error" to import error icon.

{showOrNotToShow && (
            <div
              style={{ marginTop: "15px", cursor: "pointer" }}
              onClick={() => {
                alert("something");
              }}
            >
              <ErrorIcon />
            </div>
          )}

Conditional render if error then show error icon.

Upvotes: 1

Related Questions