fix: delete Object.fromEntries ponyfill cause of bugs

This commit is contained in:
divlo 2020-10-26 02:35:56 +01:00
parent 1601626fd9
commit 4058b48959
4 changed files with 3 additions and 13 deletions

2
package-lock.json generated
View File

@ -1,6 +1,6 @@
{ {
"name": "react-component-form", "name": "react-component-form",
"version": "1.2.0", "version": "1.2.1",
"lockfileVersion": 1, "lockfileVersion": 1,
"requires": true, "requires": true,
"dependencies": { "dependencies": {

View File

@ -1,6 +1,6 @@
{ {
"name": "react-component-form", "name": "react-component-form",
"version": "1.2.0", "version": "1.2.1",
"description": "Manage React Forms with ease.", "description": "Manage React Forms with ease.",
"author": "Divlo <contact@divlo.fr>", "author": "Divlo <contact@divlo.fr>",
"license": "MIT", "license": "MIT",

View File

@ -1,9 +0,0 @@
/*! fromentries. MIT License. Feross Aboukhadijeh <https://feross.org/opensource> */
export function fromEntries<T = any>(
iterable: Iterable<readonly [PropertyKey, T]>
) {
return [...iterable].reduce((object, [key, value]) => {
object[key] = value
return object
}, {})
}

View File

@ -1,5 +1,4 @@
import React, { useRef } from 'react' import React, { useRef } from 'react'
import { fromEntries } from './fromEntries'
export interface FormDataObject { export interface FormDataObject {
[key: string]: FormDataEntryValue [key: string]: FormDataEntryValue
@ -19,7 +18,7 @@ interface FormProps extends ReactFormProps {
} }
const getFormDataObject = (formElement: HTMLFormElement): FormDataObject => { const getFormDataObject = (formElement: HTMLFormElement): FormDataObject => {
return fromEntries<FormDataEntryValue>(new FormData(formElement)) return Object.fromEntries<FormDataEntryValue>(new FormData(formElement))
} }
const Form = (props: FormProps): JSX.Element => { const Form = (props: FormProps): JSX.Element => {