-
-
Notifications
You must be signed in to change notification settings - Fork 2.8k
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
Fix UseField type definition, add micro-hooks. #3125
Fix UseField type definition, add micro-hooks. #3125
Conversation
Added Ref State. Added useSelectorComparer. Starting to build subscriptions.
…ohnrom/subscriber
use-subscriptions might not work in React 17? Seems returning the previous value doesn't bail out the render.
Sync up formik-native and formik for v3.
…te will do. If we call our own reducer then use useReducer dispatch, `state.values !== getState().values`.
…ormikReducerState + FormikComputedState. Add Fixtures and Tutorial code to /app.
Consolidate State and Add Tutorial + Fixtures.
🦋 Changeset detectedLatest commit: 00dac43 The changes in this PR will be included in the next version bump. This PR includes changesets to release 3 packages
Not sure what this means? Click here to learn what changesets are. Click here if you're a maintainer who wants to add another changeset to this PR |
@johnrom is attempting to deploy a commit to the Formium Team on Vercel. A member of the Team first needs to authorize it. |
Doesn't |
You can use Updated my description above. |
Ok, fine. Though this does look a lot uglier. const { setFieldValue } = useFormikContext();
const { value: otherValue } = useFieldMeta(props.otherFieldName);
useEffect(() => {
console.log(otherValue);
setFieldValue(props.otherFieldName, 'foo');
}, [otherValue, setValue, props.otherFieldName]); Than the previous v3 code: const [otherValue, setOtherValue] = useFieldValue(props.otherFieldName);
useEffect(() => {
console.log(otherValue);
setOtherValue('foo');
}, [otherValue, setOtherValue]); |
I agree it could be more concise. The previous concise API had a reason - the smallest possible hooks were necessary to get optimized subscriptions. This one doesn't need it, and in fact using smaller subscriptions may have a performance hit because each one is a subscription. I think a balance of this would be to return Formik API from useFieldMeta: const [fieldMeta, api] = useFieldMeta(name); |
…API. Moved FieldHelpers to their own hooks. Removed batchedUpdates since we use an Effect. Some minor type fixes, code and documentation cleanup.
…ions # Conflicts: # packages/formik/src/Formik.tsx
…hooks-and-field-fixes # Conflicts: # packages/formik/src/Field.tsx # packages/formik/src/hooks/hooks.ts # packages/formik/src/utils.ts
This pull request is stale because it has been open 30 days with no activity. Remove stale label or comment or this will be closed in 60 days |
closed in favor of #3231 |
This adds the convenience hooks from the original v3.
It doesn't add useFieldX, useSetFieldX hooks, because users should simply use
useFieldMeta()
and the relevant API methods fromuseFormikContext()
. It is not going to have a noticeable performance difference.useFieldMeta
provides the same functionality as using all theuseFieldX()
combined.