Skip to content

Commit 905a4c0

Browse files
author
ugogo
committed
support props.value
1 parent b9fe260 commit 905a4c0

File tree

2 files changed

+14
-3
lines changed

2 files changed

+14
-3
lines changed

playground/yarn.lock

Lines changed: 11 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -1529,8 +1529,12 @@
15291529
uid ""
15301530

15311531
"@types/react@*":
1532-
version "0.0.0"
1533-
uid ""
1532+
version "16.9.49"
1533+
resolved "https://registry.yarnpkg.com/@types/react/-/react-16.9.49.tgz#09db021cf8089aba0cdb12a49f8021a69cce4872"
1534+
integrity sha512-DtLFjSj0OYAdVLBbyjhuV9CdGVHCkHn2R+xr3XkBvK2rS1Y1tkc14XSGjYgm5Fjjr90AxH9tiSzc1pCFMGO06g==
1535+
dependencies:
1536+
"@types/prop-types" "*"
1537+
csstype "^3.0.2"
15341538

15351539
"@types/react@link:../node_modules/@types/react":
15361540
version "0.0.0"
@@ -3418,6 +3422,11 @@ csstype@^2.2.0:
34183422
resolved "https://registry.yarnpkg.com/csstype/-/csstype-2.6.10.tgz#e63af50e66d7c266edb6b32909cfd0aabe03928b"
34193423
integrity sha512-D34BqZU4cIlMCY93rZHbrq9pjTAQJ3U8S8rfBqjwHxkGPThWFjzZDQpgMJY0QViLxth6ZKYiwFBo14RdN44U/w==
34203424

3425+
csstype@^3.0.2:
3426+
version "3.0.3"
3427+
resolved "https://registry.yarnpkg.com/csstype/-/csstype-3.0.3.tgz#2b410bbeba38ba9633353aff34b05d9755d065f8"
3428+
integrity sha512-jPl+wbWPOWJ7SXsWyqGRk3lGecbar0Cb0OvZF/r/ZU011R4YqiRehgkQ9p4eQfo9DSDLqLL3wHwfxeJiuIsNag==
3429+
34213430
cyclist@^1.0.1:
34223431
version "1.0.1"
34233432
resolved "https://registry.yarnpkg.com/cyclist/-/cyclist-1.0.1.tgz#596e9698fd0c80e12038c2b82d6eb1b35b6224d9"

src/index.tsx

Lines changed: 3 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -13,16 +13,18 @@ type Props = {
1313
length?: number;
1414
onChange: (data: string) => any;
1515
placeholder?: string;
16+
value?: string;
1617
};
1718

1819
const ReactInputVerificationCode = ({
1920
length = 4,
2021
onChange,
2122
placeholder = '·',
23+
value: initialValue,
2224
}: Props) => {
2325
const [activeIndex, setActiveIndex] = React.useState<number>(-1);
2426
const [value, setValue] = React.useState<string[]>(
25-
new Array(length).fill(placeholder)
27+
initialValue ? initialValue.split('') : new Array(length).fill(placeholder)
2628
);
2729

2830
const codeInputRef = React.createRef<HTMLInputElement>();

0 commit comments

Comments
 (0)