From f0668453dee96508e073ca321e108a6fdd15fbef Mon Sep 17 00:00:00 2001 From: Yasas Banuka Malavige Date: Thu, 18 Dec 2025 01:53:52 +0530 Subject: [PATCH] fix: corrected misleading storeValue logic in best practices --- website/docs/write-code/best-practices.md | 18 ++++++++++-------- 1 file changed, 10 insertions(+), 8 deletions(-) diff --git a/website/docs/write-code/best-practices.md b/website/docs/write-code/best-practices.md index a046895d3b..2247ec2f85 100644 --- a/website/docs/write-code/best-practices.md +++ b/website/docs/write-code/best-practices.md @@ -45,14 +45,16 @@ In this example, the third parameter `persist` in the [storeValue()](/reference/ ```jsx export default { - fetch_name () { - storeValue('name', 'sam', true); - return appsmith.store.name; - }, - update_name () { - storeValue('name', 'ben', true); - return appsmith.store.name; - }, + // Pure getter: returns the name, or 'sam' if it's not set yet + fetch_name () { + return appsmith.store.name || 'sam'; + }, + + // Setter: correctly forces the name to change to 'ben' + update_name () { + storeValue('name', 'ben', true); + return appsmith.store.name; + }, } ``` You can then refer to the stored computed value in widgets.