Welcome to OStack Knowledge Sharing Community for programmer and developer-Open, Learning and Share
Welcome To Ask or Share your Answers For Others

Categories

0 votes
1.1k views
in Technique[技术] by (71.8m points)

reactjs - Unexpected use of 'confirm' no-restricted-globals

I am writing code for the delete confirmation for the user, but when I run it up it shows this error enter image description here

This is my code for that

    onDelete = (id) => {
      console.log(id);
      if (confirm('You want to delette ?')) {
       //eslint-disable-line
        this.props.onDelete(id);
      }
    };

Can anyone explain it to me, Please? Although I have to add //eslint-disable-line but it does not work, my problem in here is when I add //eslint-disable-line beside if (confirm('You want to delette ?')) { like this

`if (confirm('You want to delette ?')) {//eslint-disable-line`

but when I save it, it show like this

if (confirm('You want to delette ?')) {
       //eslint-disable-line

, it automatically down the line, so that the reason display error above, I do not know how to turn of the auto down line when I save

question from:https://stackoverflow.com/questions/63311845/unexpected-use-of-confirm-no-restricted-globals

与恶龙缠斗过久,自身亦成为恶龙;凝视深渊过久,深渊将回以凝视…
Welcome To Ask or Share your Answers For Others

1 Answer

0 votes
by (71.8m points)

You have to use window.confirm() instead of just confirm().


与恶龙缠斗过久,自身亦成为恶龙;凝视深渊过久,深渊将回以凝视…
Welcome to OStack Knowledge Sharing Community for programmer and developer-Open, Learning and Share
Click Here to Ask a Question

...