-
Notifications
You must be signed in to change notification settings - Fork 175
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
- Loading branch information
Showing
11 changed files
with
292 additions
and
175 deletions.
There are no files selected for viewing
2 changes: 1 addition & 1 deletion
2
docs/assets/base-80a1f760-34c3ba63.js → docs/assets/base-80a1f760-60514562.js
Some generated files are not rendered by default. Learn more about how customized files appear on GitHub.
Oops, something went wrong.
2 changes: 1 addition & 1 deletion
2
docs/assets/consoleHook-cdbe54ab-24edac1e.js → docs/assets/consoleHook-cdbe54ab-d171750f.js
Large diffs are not rendered by default.
Oops, something went wrong.
2 changes: 1 addition & 1 deletion
2
docs/assets/index-292de3b8-26ed70bb.js → docs/assets/index-292de3b8-182ab13b.js
Large diffs are not rendered by default.
Oops, something went wrong.
376 changes: 208 additions & 168 deletions
376
docs/assets/index-352e959f.js → docs/assets/index-6988ba53.js
Large diffs are not rendered by default.
Oops, something went wrong.
Large diffs are not rendered by default.
Oops, something went wrong.
Large diffs are not rendered by default.
Oops, something went wrong.
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -1 +1 @@ | ||
{"generatedAt":1707931104347,"builder":{"name":"webpack4"},"hasCustomBabel":false,"hasCustomWebpack":false,"hasStaticDirs":true,"hasStorybookEslint":false,"refCount":0,"packageManager":{"type":"npm","version":"8.19.3"},"storybookVersion":"6.5.16","language":"javascript","storybookPackages":{"@storybook/addon-options":{"version":"5.3.21"},"@storybook/addons":{"version":"6.5.16"},"@storybook/react":{"version":"6.5.16"},"@storybook/theming":{"version":"6.5.16"}},"framework":{"name":"react"},"addons":{"storybook-readme":{"version":"5.0.9"},"storybook-dark-mode":{"version":"1.1.2"}}} | ||
{"generatedAt":1708619726836,"builder":{"name":"webpack4"},"hasCustomBabel":false,"hasCustomWebpack":false,"hasStaticDirs":true,"hasStorybookEslint":false,"refCount":0,"packageManager":{"type":"npm","version":"8.19.3"},"storybookVersion":"6.5.16","language":"javascript","storybookPackages":{"@storybook/addon-options":{"version":"5.3.21"},"@storybook/addons":{"version":"6.5.16"},"@storybook/react":{"version":"6.5.16"},"@storybook/theming":{"version":"6.5.16"}},"framework":{"name":"react"},"addons":{"storybook-readme":{"version":"5.0.9"},"storybook-dark-mode":{"version":"1.1.2"}}} |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
40 changes: 40 additions & 0 deletions
40
vitedocs/Pages/ApiReference/UseFieldState/ScopedFieldState/Example.jsx
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,40 @@ | ||
import { Scope, useFieldState, Debug } from 'informed'; | ||
import { Form, Input } from 'YourComponents'; | ||
|
||
const ScopedFieldState = ({ name }) => { | ||
const { value } = useFieldState(name); | ||
return ( | ||
<pre className="language-js"> | ||
<code>{JSON.stringify(value, null, 2)}</code> | ||
</pre> | ||
); | ||
}; | ||
|
||
const UnScopedFieldState = ({ name }) => { | ||
const { value } = useFieldState(name, false); // << Note the false here | ||
return ( | ||
<pre className="language-js"> | ||
<code>{JSON.stringify(value, null, 2)}</code> | ||
</pre> | ||
); | ||
}; | ||
|
||
const Example = () => ( | ||
<div> | ||
<Form> | ||
<Scope scope="favorite"> | ||
<Input field="color" /> | ||
<h5>favorite.color: ( scoped )</h5> | ||
<ScopedFieldState name="favorite.color" /> | ||
<h5>color: ( scoped )</h5> | ||
<ScopedFieldState name="color" /> | ||
<h5>favorite.color: ( un-scoped )</h5> | ||
<UnScopedFieldState name="favorite.color" /> | ||
</Scope> | ||
<h5>Form State</h5> | ||
<Debug values /> | ||
</Form> | ||
</div> | ||
); | ||
|
||
export default Example; |
34 changes: 34 additions & 0 deletions
34
vitedocs/Pages/ApiReference/UseFieldState/ScopedFieldState/ScopedFieldState.jsx
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,34 @@ | ||
import Code from '../../../../YourComponents/Code'; | ||
import { SideBySide } from '../../../../SideBySide'; | ||
import Example from './Example'; | ||
import exampleCode from './Example.jsx?raw'; | ||
import { Info } from '../../../../Info'; | ||
|
||
export default function ScopedFieldState() { | ||
return ( | ||
<> | ||
<h1> | ||
Scoped <code>useFieldState</code> | ||
</h1> | ||
<Info> | ||
Scope is a very useful tool for simplifying your code but you can easily | ||
make mistakes when using it. | ||
<br /> | ||
<br /> | ||
Below is an example where you could misuse the useFieldState. Type into | ||
the field and Note how the text below to color: gets updated while | ||
nothing changes next to favorite.color: | ||
</Info> | ||
<Info type="notice"> | ||
Note how passing <code>false</code> as a second parameter to | ||
<code>useFieldState</code> will un scope the hook. | ||
</Info> | ||
<SideBySide | ||
leftHeader={<h3>Example: </h3>} | ||
rightHeader={<h3>Code:</h3>} | ||
left={<Example />} | ||
right={<Code links input1={exampleCode} />} | ||
/> | ||
</> | ||
); | ||
} |