What does @format mean in new react native App.js?

Viewed 5177

I started to create an Application in react native so, i setup the react native environment and found the @format in the App.js file when i open this file first time. Please can anyone tell what is @format and why it is in the new App.js file in react native?

2 Answers

Refer to the @Noitidart's link in comment, the @format is part of pragma and another pragma is @prettier. Prettier will only format those files with pragma when option of Require pragma is enabled. Thanks @Noitidart for the link.


I found this after I check the blame of App.js file in react native repo.

Prettier RN local-cli

And I found this description in RN 0.48.4 features Enforce Prettier for @format (1023070) - @TheSavior

As conclusion, the @format tag is used to tell the prettier tool to run on that file and so that it's format becomes prettier.

Its called decorators. It’s just a function that takes as an argument what it decorates:

@myFunction
class MyClass { }

is equivalent to:
class MyClass { }
myFunction(MyClass)

Using decorators allows us to extend a function (class or property) by wrapping a function (decorator) around it. This can be useful for making properties read-only or suppressing warnings from a function.

reference : https://moduscreate.com/blog/using-es2016-decorators-in-react-native/

Related