Skip to content

Commit 9b035cc

Browse files
committed
Explain why not to prefix methods with underscores
1 parent 1541503 commit 9b035cc

File tree

1 file changed

+1
-0
lines changed

1 file changed

+1
-0
lines changed

react/README.md

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -450,6 +450,7 @@
450450
```
451451
452452
- Do not use underscore prefix for internal methods of a React component.
453+
> Why? Underscore prefixes are sometimes used as a convention in other languages to denote privacy. But, unlike those languages, there is no native support for privacy in JavaScript, everything is public. Regardless of your intentions, adding underscore prefixes to your properties does not actually make them private, and any property (underscore-prefixed or not) should be treated as being public. See issues #1024, and #490 for a more in-depth discussion.
453454
454455
```jsx
455456
// bad

0 commit comments

Comments
 (0)