Skip to content

Commit c80fdda

Browse files
Define defaults in one location
This is a common issue when merging labels and assistive text objects.
1 parent e0bcddd commit c80fdda

File tree

1 file changed

+5
-0
lines changed

1 file changed

+5
-0
lines changed

docs/codebase-overview.md

Lines changed: 5 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -44,6 +44,7 @@ If you want to [contribute](/CONTRIBUTING.md), we hope that this overview will h
4444
* [React component can differ from DOM hierarchy](#react-component-can-differ-from-dom-hierarchy)
4545
* [Use loose coupling and weak connascence](#use-loose-coupling-and-weak-connascence)
4646
* [Use a single return](#use-a-single-return)
47+
* [Define defaults in one location](#define-defaults-in-one-location)
4748
* [Use functions instead of loops](#use-functions-instead-of-loops)
4849
* [No mixins](#no-mixins)
4950
* [Use one stateful component and many stateless sub-components](#use-one-stateful-component-and-many-stateless-sub-components)
@@ -375,6 +376,10 @@ The goal should be that a contributor can understand one piece of code without u
375376

376377
Please do not short-circuit functions with multiple returns.
377378

379+
#### Define defaults in one location
380+
381+
Default props or any default variable value should be defined in one location. Many objects are merged in this library and this simplifies the logic and ensures defaults are not overriding non-defaults.
382+
378383
#### Use functions instead of loops
379384

380385
`const getKittenNames = (cats) => cats.filter(isKitten).map(getName)` is a great example of how to get a list of kitten names from a `cats` collection without a `for`, `while`, or `until` loop while only modifying variables within the functional scope.

0 commit comments

Comments
 (0)