I would recommend you use the classnames library , it is a very good and useful tool.
Using
import cx from 'classnames';
...
<span className={cx('tab', {selected: this.state.signin})}>Sign In</span>
when calling a function, you can pass default values and an object to conditionally add classes in any order.
syntax: cx(default, {conditional: boolean, conditional: boolean});
syntax: cx({conditional: boolean, conditional: boolean}, default);
syntax: cx(something, {conditional: boolean}, 'something', 'something');
I prefer to use it sequentially in the order of the default string, conditional expressions. just for the convenience of reading and the others that come are easy when you expect it to be the same.
, . NPM
classNames('foo', 'bar');
classNames('foo', { bar: true });
classNames({ 'foo-bar': true });
classNames({ 'foo-bar': false });
classNames({ foo: true }, { bar: true });
classNames({ foo: true, bar: true });
classNames('foo', { bar: true, duck: false }, 'baz', { quux: true });
classNames(null, false, 'bar', undefined, 0, 1, { baz: null }, '');