Introduction
React Tips - return statement with parentheses

React Tips - return statement with parentheses

class SearchMovies extends Component {
    render() {
        return (
             <p> StarWars </p>
         )
    }
}

Notice the return statement has parentheses() not braces{}

This is because of JavaScript's automatic semicolon insertion. So, the return will have no value if we have braces, parentheses helps in overcoming that. Parentheses are not needed if JSX is in a single line.

Author

Vetrichelvan Jeyapalpandy

12 years of experience in web development. Javascript enthusiast. Performance is an important trait of any website, so trying to improve that wherever possible.

View Comments
Next Post

Quark Particles - Canvas Experiment

Previous Post

ES6 - Spread Operator