From bddf5f87ff06a0ab929a4584cd5258446379f624 Mon Sep 17 00:00:00 2001 From: mkosir Date: Thu, 28 Mar 2024 18:36:21 +0100 Subject: [PATCH] update docusaurus --- website/src/pages/index.mdx | 4 +++- 1 file changed, 3 insertions(+), 1 deletion(-) diff --git a/website/src/pages/index.mdx b/website/src/pages/index.mdx index bbdac4f7..21dee8a3 100644 --- a/website/src/pages/index.mdx +++ b/website/src/pages/index.mdx @@ -113,6 +113,8 @@ const [userRole, setUserRole] = useState('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. @@ -125,7 +127,7 @@ const removeFirstUser = (users: Array) => { return users.splice(1); }; -// ✅ Use readonly type +// ✅ Use readonly type to prevent accidental mutations const removeFirstUser = (users: ReadonlyArray) => { if (users.length === 0) { return users;