1
0
mirror of https://github.com/Unleash/unleash.git synced 2024-10-18 20:09:08 +02:00
unleash.unleash/website/docs/contributing/ADRs/front-end/preferred-function-type.md
Fredrik Strand Oseberg ad7c139992
fix: add ADR for domain language (#2541)
This PR puts our contributing guidelines in the sidebar of the unleash
documentation. Currently there was no way of navigating to them easily,
which made our contribution guides and ADRs less useful. This PR adds
them to the sidebar as their own category, and adds an ADR for domain
centric language.

Co-authored-by: Thomas Heartman <thomas@getunleash.ai>
2022-11-29 08:57:27 +01:00

24 lines
857 B
Markdown

---
title: "ADR: Preferred function type"
---
## Background
In the codebase, we have found a need to standardise function types in order to keep the codebase recognizible across different sections, and to encourage / discourage certain patterns.
## Decision
We have decided to use arrow functions across the board in the project. Both for helper functions and for react components.
```jsx
// Do:
const myFunction = () => {};
const MyComponent = () => {};
// Don't:
function myFunction() {}
function MyComponent() {}
```
The reason for this decision is to remove mental clutter and free up capacity to easily navigate the codebase. In addition, using arrow functions allows you to avoid the complexity of losing the scope of `this` for nested functions, and keeps `this` stable without any huge drawbacks. Losing hoisting is an acceptable compromise.