@mihanizm56/react-final-form-utils
Advanced tools
Comparing version 0.0.1 to 0.0.2
/// <reference types="react" /> | ||
declare type PropsType = { | ||
declare type ChangeFieldHandlerPropsType = { | ||
children: ({ value, name }: { | ||
@@ -9,3 +9,3 @@ value: any; | ||
}; | ||
export declare const ChangeFieldHandler: ({ name, children }: PropsType) => JSX.Element; | ||
export declare const ChangeFieldHandler: ({ name, children, }: ChangeFieldHandlerPropsType) => JSX.Element; | ||
export {}; |
@@ -1,3 +0,17 @@ | ||
import React from 'react'; | ||
import React, { useState, useEffect } from 'react'; | ||
import { Field } from 'react-final-form'; | ||
var InternalHook = function (_a) { | ||
var formValue = _a.formValue, callback = _a.callback, name = _a.name; | ||
var _b = useState(null), value = _b[0], setValue = _b[1]; | ||
useEffect(function () { | ||
if (value !== formValue) { | ||
setValue(formValue); | ||
callback({ | ||
name: name, | ||
value: formValue, | ||
}); | ||
} | ||
}, [callback, formValue, name, value]); | ||
return null; | ||
}; | ||
export var ChangeFieldHandler = function (_a) { | ||
@@ -7,8 +21,4 @@ var name = _a.name, children = _a.children; | ||
var value = _a.input.value; | ||
children({ | ||
name: name, | ||
value: value, | ||
}); | ||
return null; | ||
return (React.createElement(InternalHook, { formValue: value, callback: children, name: name })); | ||
})); | ||
}; |
{ | ||
"name": "@mihanizm56/react-final-form-utils", | ||
"version": "0.0.1", | ||
"version": "0.0.2", | ||
"description": "form utils module", | ||
@@ -5,0 +5,0 @@ "main": "dist/index.js", |
License Policy Violation
LicenseThis package is not allowed per your license policy. Review the package's license to ensure compliance.
Found 1 instance in 1 package
License Policy Violation
LicenseThis package is not allowed per your license policy. Review the package's license to ensure compliance.
Found 1 instance in 1 package
5687
35