Skip to content

Commit e71c9d4

Browse files
committed
[docs] Add omitExtraData docs
1 parent 080092c commit e71c9d4

File tree

2 files changed

+23
-2
lines changed

2 files changed

+23
-2
lines changed

.changeset/chilled-rats-check.md

Lines changed: 5 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,5 @@
1+
---
2+
"docs": patch
3+
---
4+
5+
Add `omitExtraData` docs

apps/docs/src/content/docs/advanced/state-transformation.mdx

Lines changed: 18 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -8,11 +8,27 @@ In some cases it may be necessary to transform the form state before it is passe
88

99
You can do this by providing `getSnapshot` attribute.
1010

11+
## Omit extra data
12+
13+
One of the transformation options you can apply is deleting unnecessary data.
14+
15+
For this you can use `omitExtraData` function.
16+
17+
:::note
18+
19+
Currently function `omitExtraData` is imported from `@sjsf/form/legacy-omit-extra-data` and
20+
will be deprecated because it's implementation does not meet the requirements of our code base.
21+
22+
It will be replaced with `@sjsf/form/omit-extra-data` import in the major release.
23+
24+
:::
25+
1126
```svelte
1227
<script lang="ts">
1328
import { Form } from "@sjsf/form";
1429
import { translation } from "@sjsf/form/translations/en";
1530
import { theme } from "@sjsf/form/basic-theme";
31+
import { omitExtraData } from "@sjsf/form/legacy-omit-extra-data";
1632
1733
import { schema, uiSchema, initialData } from "./schema";
1834
import { validator } from "./validator";
@@ -28,7 +44,7 @@ You can do this by providing `getSnapshot` attribute.
2844
{uiSchema}
2945
{validator}
3046
{translation}
31-
getSnapshot={() => transform($state.snapshot(value))}
47+
getSnapshot={() => omitExtraData(validator, schema, $state.snapshot(value))}
3248
onSubmit={(value) => {
3349
console.log("transformed", value);
3450
}}
@@ -37,4 +53,4 @@ You can do this by providing `getSnapshot` attribute.
3753
console.log("transformed", value);
3854
}}
3955
/>
40-
```
56+
```

0 commit comments

Comments
 (0)