nebius/SWE-rebench-V2-PRs huggingface dataset:
Repository: jaredpalmer/formik
Pull request #609 (2018-05-02 10:26:01)

fix withFormik display name
Previously any debugger that uses displayName would report the component wrapped with `withFormik` as `C`. This change makes it such that debuggers will now resolve it as `withFormik(ComponentName)`.

Should fix the issue raised in #310 (~4 months is long enough to assume he's not going to raise the PR I think).

jaredpalmer: Lgtm

Patch:
diff --git a/src/withFormik.tsx b/src/withFormik.tsx
index 875b782..42f2a20 100644
--- a/src/withFormik.tsx
+++ b/src/withFormik.tsx
@@ -109,11 +109,18 @@ export function withFormik<
   return function createFormik(
     Component: CompositeComponent<InjectedFormikProps<Props, Values>>
   ): React.ComponentClass<Props> {
+    const componentDisplayName =
+      Component.displayName ||
+      Component.name ||
+      (Component.constructor && Component.constructor.name) ||
+      'Component';
     /**
      * We need to use closures here for to provide the wrapped component's props to
      * the respective withFormik config methods.
      */
     class C extends React.Component<Props, {}> {
+      static displayName = `WithFormik(${componentDisplayName})`;
+
       validate = (values: Values): void | object | Promise<any> => {
         return config.validate!(values, this.props);
       };


Test patch:
diff --git a/test/withFormik.test.tsx b/test/withFormik.test.tsx
index 0bb9a6e..796f37f 100644
--- a/test/withFormik.test.tsx
+++ b/test/withFormik.test.tsx
@@ -76,6 +76,11 @@ describe('withFormik()', () => {
     expect(tree.find(Form).props().isValid).toBe(false);
   });
 
+  it('should correctly set displayName', () => {
+    const tree = mount(<BasicForm user={{ name: 'jared' }} />);
+    expect((tree.get(0).type as any).displayName).toBe('WithFormik(Form)');
+  });
+
   describe('FormikHandlers', () => {
     describe('handleChange', () => {
       it('sets values state', async () => {
Repository: jaredpalmer/formik
Pull request #840 (2018-08-22 12:21:21)

fix MultistepWizard example
We have to pass `bag` needed by `App` to call `setSubmitting()`.


Patch:
diff --git a/examples/MultistepWizard.js b/examples/MultistepWizard.js
index 183bff8..3199380 100644
--- a/examples/MultistepWizard.js
+++ b/examples/MultistepWizard.js
@@ -48,7 +48,7 @@ class Wizard extends React.Component {
     const { page } = this.state;
     const isLastPage = page === React.Children.count(children) - 1;
     if (isLastPage) {
-      return onSubmit(values);
+      return onSubmit(values, bag);
     } else {
       this.next(values);
       bag.setSubmitting(false);
diff --git a/src/FieldArray.tsx b/src/FieldArray.tsx
index 499523c..2d27c6a 100644
--- a/src/FieldArray.tsx
+++ b/src/FieldArray.tsx
@@ -1,4 +1,5 @@
 import * as React from 'react';
+import cloneDeep from 'lodash.clonedeep';
 import { connect } from './connect';
 import {
   FormikContext,
@@ -125,7 +126,7 @@ class FieldArrayInner<Values = {}> extends React.Component<
 
   push = (value: any) =>
     this.updateArrayField(
-      (array: any[]) => [...(array || []), value],
+      (array: any[]) => [...(array || []), cloneDeep(value)],
       false,
       false
     );


Test patch:
diff --git a/test/FieldArray.test.tsx b/test/FieldArray.test.tsx
index 67f5380..6a88731 100644
--- a/test/FieldArray.test.tsx
+++ b/test/FieldArray.test.tsx
@@ -95,6 +95,37 @@ describe('<FieldArray />', () => {
       const expected = ['jared', 'andrea', 'brent', 'jared'];
       expect(formikBag.values.friends).toEqual(expected);
     });
+    it('should push clone not actual referance', () => {
+      let personTemplate = { firstName: '', lastName: '' };
+      let formikBag: any;
+      let arrayHelpers: any;
+      ReactDOM.render(
+        <TestForm
+          initialValues={{ people: [] }}
+          render={(props: any) => {
+            formikBag = props;
+            return (
+              <FieldArray
+                name="people"
+                render={arrayProps => {
+                  arrayHelpers = arrayProps;
+                  return null;
+                }}
+              />
+            );
+          }}
+        />,
+        node
+      );
+
+      arrayHelpers.push(personTemplate);
+      expect(
+        formikBag.values.people[formikBag.values.people.length - 1]
+      ).not.toBe(personTemplate);
+      expect(
+        formikBag.values.people[formikBag.values.people.length - 1]
+      ).toMatchObject(personTemplate);
+    });
   });
 
   describe('props.pop()', () => {