Skip to content

Commit

Permalink
Revert update handler on each state change. Bad idea :)
Browse files Browse the repository at this point in the history
  • Loading branch information
sebelga committed Aug 28, 2020
1 parent 62289f6 commit 8e82be6
Showing 1 changed file with 1 addition and 5 deletions.
Original file line number Diff line number Diff line change
Expand Up @@ -52,13 +52,9 @@ export const useFormData = <T extends object = FormData>(options: Options = {}):
const isMounted = useRef(false);
const [formData, setFormData] = useState<FormData>(previousRawData.current);

// Create a new instance of the "formatFormData()" handler whenever the "formData" state changes
// so the consumer can interchangeably declare the "formData" state or the "format()" handler as
// dependency in his useEffect().
// This is the reason why we disable the react-hooks/exhaustive-deps rule
const formatFormData = useCallback(() => {
return getFormData({ unflatten: true });
}, [formData, getFormData]); // eslint-disable-line react-hooks/exhaustive-deps
}, [getFormData]);

useEffect(() => {
const subscription = getFormData$().subscribe((raw) => {
Expand Down

0 comments on commit 8e82be6

Please sign in to comment.