lundi 5 octobre 2020

When and how to use semi colons in react js(and when not to)

Hey I am beginner in react js and in the field of web dev. Can someone give a thumb rule or tricks to identify when to use a semi colon and when not to. For eg- in a demo code , one component had a semicolon in return function while the other dint (both were const function) and when I swapped the semi colons in both components the app crashed. Thanks in advance

without semicolon

import React from 'react'

const Notification=()=>{
    return(
        <div>
            <p>Notification</p>
        </div>    
       
    )
}
export default Notification

with semicolon

import React from 'react'
import {Link, NavLink} from 'react-router-dom'
import Navbar from './Navbar'

const Sighnedlinks=()=>{
    return(    
        <ul className="right">
            <li><NavLink to="/">Add New Project</NavLink></li>
            <li><NavLink to="/">Log Out</NavLink></li>
            <li><NavLink to="/" className="btn btn-floating pink lighten-1">NN</NavLink></li>
        </ul>

    );
}
export default Sighnedlinks



Aucun commentaire:

Enregistrer un commentaire