conditional rendering react

JavaScript
function Mailbox(props) {
  const unreadMessages = props.unreadMessages;
  return (
    <div>
      <h1>Hello!</h1>
      {unreadMessages.length > 0 &&
        <h2>
          You have {unreadMessages.length} unread messages.
        </h2>
      }
    </div>
  );
}render() {
  const isLoggedIn = this.state.isLoggedIn;
  return (
    <div>
      The user is <b>{isLoggedIn ? 'currently' : 'not'}</b> logged in.    </div>
  );
}import React, { Component } from 'react';

// @params [] * denotes optional param (we will need to use conditional rendering for some of these)
// [type](Bulma CSS class): Hero type, focuses on the base styling
// size(Bulma CSS Class): The size of the hero, small, medium, large, etc...
// heading: The main heading
// [subheading]: The subheading if desired
// [alignment](Bulma CSS Class): Aligns the content horizontally

// This Simple HeroComponent is bases upon the following
// https://bulma.io/documentation/layout/hero/ 

export class HeroComponent extends Component
{
	render() {
		return (
          	// The following ternary simply applies a class if it has been specified
			<section className={"hero" + (this.props.type ? " " + this.props.type + " " : " ") + this.props.size}>
				<div className="hero-body">
                  	// Again, another ternary applying a class... blah blah blah....
					<div className={"container" + this.props.alignment ? " " + this.props.alignment : ""}>
						<h1 className="title">{this.props.heading}</h1>
						// So, to answer the question...
						// The following is one way to do conditional rendering, probably the simplest and cleanest
						// If this.props.subheading exists, render <h2 .. />
						{this.props.subheading && <h2 className="subtitle">{this.props.subheading}</h2>}
					</div>
				</div>
			</section>
		)
	}
}// This JSX:
<div id={if (condition) { 'msg' }}>Hello World!</div>

// Is transformed to this JS:
React.createElement("div", {id: if (condition) { 'msg' }}, "Hello World!");
renderElement(){
   if(this.state.value == 'news')
      return <Text>data</Text>;
   return null;
}

render() {
    return (   
        <View style={styles.container}>
            { this.renderElement() }
        </View>
    )
}lass LoginControl extends React.Component {
  constructor(props) {
    super(props);
    this.handleLoginClick = this.handleLoginClick.bind(this);
    this.handleLogoutClick = this.handleLogoutClick.bind(this);
    this.state = {isLoggedIn: false};
  }

  handleLoginClick() {
    this.setState({isLoggedIn: true});
  }

  handleLogoutClick() {
    this.setState({isLoggedIn: false});
  }

  render() {
    const isLoggedIn = this.state.isLoggedIn;
    let button;
    if (isLoggedIn) {
      button = <LogoutButton onClick={this.handleLogoutClick} />;
    } else {
      button = <LoginButton onClick={this.handleLoginClick} />;
    }

    return (
      <div>
        <Greeting isLoggedIn={isLoggedIn} />
        {button}
      </div>
    );
  }
}

ReactDOM.render(
  <LoginControl />,
  document.getElementById('root')
);
Source

Also in JavaScript: