1

There is a component that must be build which must receive a function for onClick. The problem is that the function is not defined yet so it must receive some 'empty' function in order to pass the tests.

This is the code:

  <Button
    title='MyTitle'
    className='my-class-name'
    onClick={
      () =>
        /* eslint-disable no-console */
        console.log('test')
      /* eslint-enable no-console */
    }
  />

So I added a console.log() but eslint doesn't like it so the comments before and after it were added.

Is there a way to put a function that doesn't do anything just to pass the linting?

1

3 Answers 3

2

The function can just return null:

   <Button
        title='MyTitle'
        className='my-class-name'
        onClick={() => null}
    />
Sign up to request clarification or add additional context in comments.

Comments

1

Use this:

<Button
    title='MyTitle'
    className='my-class-name'
    onClick={
      () => undefined
    }
  />

Comments

0

Maybe try returning void instead?

onClick={() => void 0}

1 Comment

it doesn't work. should void0 be defined somewhere?

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service and acknowledge you have read our privacy policy.

Start asking to get answers

Find the answer to your question by asking.

Ask question

Explore related questions

See similar questions with these tags.