From e05ad32e10352d456849301056457262308cdebf Mon Sep 17 00:00:00 2001 From: Ethan Zhang Date: Mon, 9 Dec 2024 15:02:59 +0800 Subject: [PATCH] Update recommend-practices.md --- docs/recommend-practices.md | 8 +++++++- 1 file changed, 7 insertions(+), 1 deletion(-) diff --git a/docs/recommend-practices.md b/docs/recommend-practices.md index 21f1a94..55e3350 100644 --- a/docs/recommend-practices.md +++ b/docs/recommend-practices.md @@ -2,7 +2,7 @@ ## Naming -Add a suffix `Atom` to `Value` & `Computed`, and use `Effect` for `Effect`. Since we often need to get values from Atoms in many scenarios, adding the suffix after Atom can avoid naming conflicts. +Add the suffix `Atom` to `Value` and `Computed` and use `Effect` for `Effect`. Since we often need to get values from Atoms in many scenarios, adding the suffix after Atom can avoid naming conflicts. ```typescript const countAtom = $value(0); @@ -10,6 +10,12 @@ const doubleAtom = $computed((get) => get(countAtom) * 2); const updateCountEffect = $effect((get, set, val) => { set(countAtom, val); }); +// ... +const count = get(countAtom) // will not conflict with normal value +// in react component +const updateCount = useSet(updateCountEffect) // Effect suffix is useful for this + +return ``` ## Do not use `store` directly