Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
* improve on getting value * remove extra function * remove default value as empty string * 馃 upgrade dev packages * fix automation * fix automation * fix build issue * fix build issue * fix bundlesize * more imporvement * more imporvement * more code clean up * fix the issue introduced
- Loading branch information
1 parent
4e6c91d
commit 2384e4e
Showing
6 changed files
with
643 additions
and
681 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,14 @@ | ||
import typescript from 'rollup-plugin-typescript2'; | ||
import { terser } from 'rollup-plugin-terser'; | ||
|
||
export default { | ||
input: 'src/index.ts', | ||
plugins: [typescript(), terser()], | ||
external: ['react', 'react-dom'], | ||
output: [ | ||
{ | ||
file: 'dist/react-hook-form.min.es.js', | ||
format: 'es', | ||
}, | ||
], | ||
}; |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -1,8 +1,15 @@ | ||
import get from '../utils/get'; | ||
import { DataType } from '../types'; | ||
import { FieldValue } from '../types'; | ||
|
||
export default ( | ||
defaultValues: DataType | undefined, | ||
name: string, | ||
): DataType | string | number | boolean => | ||
defaultValues && (defaultValues[name] || get(defaultValues, name)); | ||
export default function getDefaultValue< | ||
Data extends FieldValue, | ||
Name extends keyof Data = keyof Data | ||
>( | ||
defaultValues: Partial<Data>, | ||
name: Name, | ||
defaultValue?: any, | ||
): Data[Name] | undefined { | ||
return ( | ||
defaultValues[name] || get(defaultValues, name as string, defaultValue) | ||
); | ||
} |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Oops, something went wrong.