Skip to content

Commit

Permalink
update docusaurus
Browse files Browse the repository at this point in the history
  • Loading branch information
mkosir committed Mar 28, 2024
1 parent cd0661d commit bddf5f8
Showing 1 changed file with 3 additions and 1 deletion.
4 changes: 3 additions & 1 deletion website/src/pages/index.mdx
Original file line number Diff line number Diff line change
Expand Up @@ -113,6 +113,8 @@ const [userRole, setUserRole] = useState<UserRole>('admin'); // Type 'UserRole'

Majority of the data should be immutable with use of `Readonly`, `ReadonlyArray`.

Using readonly type prevents accidental data mutations, which reduces the risk of introducing bugs related to unintended side effects.

When performing data processing always return new array, object etc. To keep cognitive load for future developers low, try to keep data objects small.
As an exception mutations should be used sparingly in cases where truly necessary: complex objects, performance reasoning etc.

Expand All @@ -125,7 +127,7 @@ const removeFirstUser = (users: Array<User>) => {
return users.splice(1);
};

// ✅ Use readonly type
// ✅ Use readonly type to prevent accidental mutations
const removeFirstUser = (users: ReadonlyArray<User>) => {
if (users.length === 0) {
return users;
Expand Down

0 comments on commit bddf5f8

Please sign in to comment.