From abbcd703973b44605d88fcc4274fa1de901f6124 Mon Sep 17 00:00:00 2001 From: David Maskasky Date: Tue, 3 Oct 2023 13:52:03 -0700 Subject: [PATCH] update readme --- src/mutableAtom/README.md | 34 +++++++++++----------------------- 1 file changed, 11 insertions(+), 23 deletions(-) diff --git a/src/mutableAtom/README.md b/src/mutableAtom/README.md index 981c991..31dc927 100644 --- a/src/mutableAtom/README.md +++ b/src/mutableAtom/README.md @@ -75,19 +75,6 @@ atomWithProxy(proxyObject, { sync: true }) `mutableAtom` wraps a value in a self-aware Valtio proxy. You can make changes to it in the same way you would to a normal js-object. -### API Signature - -```jsx -function mutableAtom(value: Value, options?: Options): Atom<{ value: Value}> -``` - -### Parameters - -- **value** (required): the value to proxy. -- **options** (optional): allows customization with `proxyFn` for custom proxy functions. - -### Example - Count value is stored under the `value` property. ```jsx @@ -99,22 +86,23 @@ function IncrementButton() { } ``` - +### Parameters -### Options +```js +mutableAtom(value, options?) +``` -Options include `proxyFn` which can be `proxy` or a custom function. +**value** (required): the value to proxy. -```jsx -type ProxyFn = (obj: { value: Value }) => ({ value: Value }) +**options.proxyFn** (optional): allows customization with `proxyFn` for custom proxy functions. Can be `proxy` (default) or a custom function. -type Options = { - proxyFn: ProxyFn -} -``` +### Examples + + ### Caution on Mutating Proxies -Be careful not to mutate the proxy directly in the atom's read function or during render in React components. Doing so might trigger an infinite render loop. + +Be careful to not mutate the proxy directly in the atom's read function or during render. Doing so could cause an infinite render loop. ```ts const countProxyAtom = mutableAtom(0)