JavaScript How to avoid a jQuery call in ReactJS

I know JQuery is a code smell in ReactJS because it traverses the entire DOM to do it's work. But, I've found some places where it's hard NOT to use it. This is one instance where I'd like to find a better way if possible.

I'm just trying to show or hide a message on a div based on whether or not a field is populated...

javascript:

if (this.props.loginInfo.userId === ''){
     $("#errorMessageDiv").attr('class', 'visible');
} else{
     $("#errorMessageDiv").attr('class', 'invisible');
}

jsx:

<div id="errorMessageDiv" className="invisible">
     <h1 id="credentials" className="login-error-message">&nbsp;Please Enter Proper Credentials</h1>
</div>
Answer:1

I recommend you to take a look at classnames library.

Basically what it does, adds or removes classnames you like, if you have classnames that has no condition just pass true. See the following snippet.

import classNames  from 'classnames'

<div 
  id="errorMessageDiv"
  className={ classNames({
    'visible' : this.props.loginInfo.userId === '',
    'invisible' : this.props.loginInfo.userId !== '',
    'some-other-class-name' : your_condition,
    'will-be-available-definetely' : true
  }) }
>
     <h1 id="credentials" className="login-error-message">&nbsp;Please Enter Proper Credentials</h1>
</div>

If you have only one condition, you can do the following :

import classNames  from 'classnames'

<div 
  id="errorMessageDiv" 
  className={ this.props.loginInfo.userId === '' ? 'visible' : 'invisible' }
>
     <h1 id="credentials" className="login-error-message">&nbsp;Please Enter Proper Credentials</h1>
</div>
Answer:2

I'm kind of stuck here in this situation, where I need my app to reload when changing from one "project" to another. I've tried many things and I have been searching over and over to find a solution. ...

I'm kind of stuck here in this situation, where I need my app to reload when changing from one "project" to another. I've tried many things and I have been searching over and over to find a solution. ...

  1. angularjs ui-sref-opts

As explained in mdn, custom elements may be based on a native element. For Example, <button is="my-button">. What I'm looking for is kind of the opposite syntax. I'd like a shorthand for ...

As explained in mdn, custom elements may be based on a native element. For Example, <button is="my-button">. What I'm looking for is kind of the opposite syntax. I'd like a shorthand for ...

I'm using the awesome Slick slide on a project. The problem is: I have a carousel with 5 divs inside. 4 images and a video. On mobile (< 768px) I want the slider to show only the images, not the ...

I'm using the awesome Slick slide on a project. The problem is: I have a carousel with 5 divs inside. 4 images and a video. On mobile (< 768px) I want the slider to show only the images, not the ...

  1. remove slick slider jquery
  2. remove slick slider
  3. slick remove slide
  4. slick remove slide by class
  5. slick remove first slide
  6. slick remove last slide
  7. slick slider remove arrows
  8. slick slider remove slide
  9. slick slider remove clone
  10. slick slider remove outline
  11. slick slider dots remove numbers
  12. slick slider remove buttons
  13. slick slider remove arrow text
  14. slick slider remove blue outline
  15. slick slider remove dots
  16. slick slider remove tabindex
  17. slick slider remove draggable
  18. slick slider remove all slides
  19. slick slider remove transform
  20. slick slider remove animation

I have this button <button id="<?php echo $u['id']?>" name="activation" onclick="handleButton(this);" type="submit" class="btn btn-success"></button> And this button related to ...

I have this button <button id="<?php echo $u['id']?>" name="activation" onclick="handleButton(this);" type="submit" class="btn btn-success"></button> And this button related to ...

  1. send value controller to view
  2. send value from controller to view mvc
  3. send value from controller to view codeigniter
  4. send value from controller to view laravel
  5. send value to controller mvc
  6. send value to controller angularjs
  7. send value from controller to javascript
  8. send value from controller to jsp
  9. send value to controller ajax
  10. send value to controller
  11. send value to controller jquery
  12. send value from one controller to another
  13. send checkbox value to controller mvc
  14. send textbox value to controller mvc
  15. send value from javascript to controller mvc
  16. send button value to controller
  17. send dropdown value to controller using ajax
  18. thymeleaf send value to controller
  19. send value from jsp to controller spring
  20. send checkbox value to controller mvc c#