8000 followup from prior releases by quantizor · Pull Request #3813 · jaredpalmer/formik · GitHub
[go: up one dir, main page]
More Web Proxy on the site http://driver.im/
Skip to content

followup from prior releases #3813

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

Merged
merged 6 commits into from
May 31, 2023
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension


Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
5 changes: 5 additions & 0 deletions .changeset/rare-cars-compete.md
Original file line number Diff line number Diff line change
@@ -0,0 +1,5 @@
---
'formik': patch
---

Revert `FieldArray` "shouldComponentUpdate" performance optimization. As it turns out, it's a common use case to have JSX controlled via non-Formik state/props inside of `FieldArray`, so it's not safe to cancel re-renders here.
15 changes: 2 additions & 13 deletions .github/workflows/playwright.yml
Original file line number Diff line number Diff line change
Expand Up @@ -12,22 +12,11 @@ jobs:
- uses: actions/checkout@v3
- uses: actions/setup-node@v3
with:
cache: yarn
node-version: 18

- name: Get yarn cache directory path
id: yarn-cache-dir-path
run: echo "dir=$(yarn cache dir)" >> $GITHUB_OUTPUT

- uses: actions/cache@v3
id: yarn-cache # use this to check for `cache-hit` (`steps.yarn-cache.outputs.cache-hit != 'true'`)
with:
path: ${{ steps.yarn-cache-dir-path.outputs.dir }}
key: ${{ runner.os }}-yarn-${{ hashFiles('**/yarn.lock') }}
restore-keys: |
${{ runner.os }}-yarn-

- name: Install dependencies
run: yarn
run: yarn install --frozen-lockfile

- name: Get installed Playwright version
id: playwright-version
Expand Down
18 changes: 3 additions & 15 deletions .github/workflows/release.yml
8000
Original file line number Diff line number Diff line change
Expand Up @@ -13,22 +13,10 @@ jobs:
with:
fetch-depth: 0

- name: Use Node.js 18.x
uses: actions/setup-node@v3
- uses: actions/setup-node@v3
with:
node-version: 18.x

- name: Get yarn cache directory path
id: yarn-cache-dir-path
run: echo "dir=$(yarn cache dir)" >> $GITHUB_OUTPUT

- uses: actions/cache@v3
id: yarn-cache # use this to check for `cache-hit` (`steps.yarn-cache.outputs.cache-hit != 'true'`)
with:
path: ${{ steps.yarn-cache-dir-path.outputs.dir }}
key: ${{ runner.os }}-yarn-${{ hashFiles('**/yarn.lock') }}
restore-keys: |
${{ runner.os }}-yarn-
cache: yarn
node-version: 18

- name: Install Dependencies
run: yarn install
Expand Down
15 changes: 2 additions & 13 deletions .github/workflows/test.yml
Original file line number Diff line number Diff line change
Expand Up @@ -20,25 +20,14 @@ jobs:
- name: Use Node.js ${{ matrix.node }}
uses: actions/setup-node@v3
with:
cache: yarn
node-version: ${{ matrix.node }}

- name: Get yarn cache directory path
id: yarn-cache-dir-path
run: echo "dir=$(yarn cache dir)" >> $GITHUB_OUTPUT

- uses: actions/cache@v3
id: yarn-cache # use this to check for `cache-hit` (`steps.yarn-cache.outputs.cache-hit != 'true'`)
with:
path: ${{ steps.yarn-cache-dir-path.outputs.dir }}
key: ${{ runner.os }}-yarn-${{ hashFiles('**/yarn.lock') }}
restore-keys: |
${{ runner.os }}-yarn-

- name: Install deps, build, and test
run: |
node --version
npm --version
yarn --version
yarn --version
yarn install --frozen-lockfile
yarn test --coverage
env:
Expand Down
10 changes: 10 additions & 0 deletions packages/formik/README.md
Original file line number Diff line number Diff line change
Expand Up @@ -25,6 +25,16 @@
- Jared Palmer [@jaredpalmer](https://twitter.com/jaredpalmer)
- Ian White [@eonwhite](https://twitter.com/eonwhite)

## Contributing

This monorepo uses `yarn`, so to start you'll need the package manager installed.

To run E2E tests you'll also need Playwright set up, which can be done locally via `npx playwright install`. Afterward, run `yarn start:app` and in a separate tab run `yarn e2e:ui` to boot up the test runner.

When you're done with your changes, we use [changesets](https://github.com/changesets/changesets) to manage release notes. Run `yarn changeset` to autogenerate notes to be appended to your pull request.

Thank you!

## Contributors

Formik is made with <3 thanks to these wonderful people
Expand Down
22 changes: 0 additions & 22 deletions packages/formik/src/FieldArray.tsx
Original file line number Diff line number Diff line change
Expand Up @@ -27,8 +27,6 @@ export type FieldArrayConfig = {
name: string;
/** Should field array validate the form AFTER array updates/changes? */
validateOnChange?: boolean;
/** Override FieldArray's default shouldComponentUpdate */
shouldUpdate?: (nextProps: {}, props: {}) => boolean;
} & SharedRenderProps<FieldArrayRenderProps>;
export interface ArrayHelpers<T extends any[] = any[]> {
/** Imperatively add a value to the end of an array */
Expand Down Expand Up @@ -155,26 +153,6 @@ class FieldArrayInner<Values = {}> extends React.Component<
this.pop = this.pop.bind(this) as any;
}

shouldComponentUpdate(props: any) {

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Did you intend to delete this? (although this is actually breaking my code when a component returned by the render function depends on local state.)

Copy link
Collaborator Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

I intended to revert the change yes.

if (this.props.shouldUpdate) {
return this.props.shouldUpdate(props, this.props);
} else if (
props.name !== this.props.name ||
getIn(props.formik.values, this.props.name) !==
getIn(this.props.formik.values, this.props.name) ||
getIn(props.formik.errors, this.props.name) !==
getIn(this.props.formik.errors, this.props.name) ||
getIn(props.formik.touched, this.props.name) !==
getIn(this.props.formik.touched, this.props.name) ||
Object.keys(this.props).length !== Object.keys(props).length ||
props.formik.isSubmitting !== this.props.formik.isSubmitting
) {
return true;
} else {
return false;
}
}

componentDidUpdate(
prevProps: FieldArrayConfig & { formik: FormikContextType<Values> }
) {
Expand Down
15 changes: 9 additions & 6 deletions playwright.config.ts
Original file line number Diff line number Diff line change
@@ -1,4 +1,4 @@
import { defineConfig, devices } from '@playwright/test';
import { PlaywrightTestProject, defineConfig, devices } from '@playwright/test';

/**
* Read environment variables from file.
Expand Down Expand Up @@ -42,10 +42,13 @@ export default defineConfig({
use: { ...devices['Desktop Firefox'] },
},

{
name: 'webkit',
use: { ...devices['Desktop Safari'] },
},
// this one does not seem to be functional in github actions
!process.env.CI
? {
name: 'webkit',
use: { ...devices['Desktop Safari'] },
}
: null,

/* Test against mobile viewports. */
// {
Expand All @@ -66,7 +69,7 @@ export default defineConfig({
// name: 'Google Chrome',
// use: { ..devices['Desktop Chrome'], channel: 'chrome' },
// },
],
].filter(Boolean) as PlaywrightTestProject[],

/* Run your local dev server before starting the tests */
webServer: {
Expand Down
0