@fairys/rn-valtio-form-basic 0.0.13 → 1.0.0

This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
@@ -16,7 +16,7 @@ function useFairysValtioFormItemAttrs(props) {
16
16
  const parent_isInvalidBorderRed = layoutAttrs.isInvalidBorderRed;
17
17
  const parent_isInvalidTextRed = layoutAttrs.isInvalidTextRed;
18
18
  const parent_showColon = layoutAttrs.showColon;
19
- const { name, valuePropName = 'value', getValuePath = 'text', getValueFromEvent, formatValue, onAfterUpdate, trigger = 'onChange', style, labelStyle, bodyStyle, children, labelMode = parent_labelMode, errorLayout = parent_errorLayout, colSpan = 1, isRequired: _isRequired, itemBorderType = parent_borderedType, attrs = {}, showColon = parent_showColon, itemBorderColor = parent_itemBorderColor, isInvalidBorderRed = parent_isInvalidBorderRed, isInvalidTextRed = parent_isInvalidTextRed, isJoinParentField = true, rules } = props;
19
+ const { name, valuePropName = 'value', getValuePath = 'text', getValueFromEvent, formatValue, onAfterUpdate, trigger = 'onChange', style, labelStyle, bodyStyle, children, labelMode = parent_labelMode, errorLayout = parent_errorLayout, colSpan = 1, isRequired: _isRequired, itemBorderType = parent_borderedType, attrs = {}, showColon = parent_showColon, itemBorderColor = parent_itemBorderColor, isInvalidBorderRed = parent_isInvalidBorderRed, isInvalidTextRed = parent_isInvalidTextRed, isJoinParentField = true, rules, isRemoveValueOnUnmount = true } = props;
20
20
  const { name: _name, paths, parentName, formAttrsNameInstance } = useFairysValtioFormAttrsName({
21
21
  name,
22
22
  isJoinParentField
@@ -50,6 +50,9 @@ function useFairysValtioFormItemAttrs(props) {
50
50
  _name,
51
51
  rules
52
52
  ]);
53
+ useEffect(()=>()=>{
54
+ if (isRemoveValueOnUnmount) formInstance.removeValueByPaths(_name);
55
+ }, []);
53
56
  const onValueChange = (event)=>{
54
57
  let newValue = event;
55
58
  const target = event?.nativeEvent;
@@ -213,7 +216,7 @@ function useFairysValtioFormItemAttrs(props) {
213
216
  };
214
217
  }
215
218
  function useFairysValtioFormItemNoStyleAttrs(props) {
216
- const { name, valuePropName = 'value', getValuePath = 'text', getValueFromEvent, formatValue, onAfterUpdate, trigger = 'onChange', children, attrs = {}, isJoinParentField = true, rules, isRequired: _isRequired } = props;
219
+ const { name, valuePropName = 'value', getValuePath = 'text', getValueFromEvent, formatValue, onAfterUpdate, trigger = 'onChange', children, attrs = {}, isJoinParentField = true, rules, isRequired: _isRequired, isRemoveValueOnUnmount = true } = props;
217
220
  const [state, errorState, formInstance] = useFairysValtioFormInstanceContextState();
218
221
  const { name: _name, paths, parentName, formAttrsNameInstance } = useFairysValtioFormAttrsName({
219
222
  name,
@@ -236,6 +239,9 @@ function useFairysValtioFormItemNoStyleAttrs(props) {
236
239
  _name,
237
240
  rules
238
241
  ]);
242
+ useEffect(()=>()=>{
243
+ if (isRemoveValueOnUnmount) formInstance.removeValueByPaths(_name);
244
+ }, []);
239
245
  const onValueChange = (event)=>{
240
246
  let newValue = event;
241
247
  const target = event?.nativeEvent;