re: React.js Frequently Faced Problems VIEW POST


hi, samer i had an one question that when i was going through various tutorials for react, i found out strings in a state component were all written in capital letters

for eg. (reference: image uploaded)
can you please help me by telling why letters are capitalized in string in this case

onDeleteClick = async (id, dispatch) => {

    dispatch({type: 'DELETE_CONTACT', payload: id});
    } catch(e){
        dispatch({type: 'DELETE_CONTACT', payload: id});        }

and this example which i have practiced


It's just a common practice to do for strings that are supposed to be unique fixed values in a program. There is no syntax significance to this. You can use lower case values and things will still work.

In modern JS, you can use the "symbol" primitive type to provide unique values and it's a much better deal than using just strings (regardless of their case).

Code of Conduct Report abuse