Skip to content

Commit db5c4ea

Browse files
committed
Update CVV and Expiry date
1 parent 192e38c commit db5c4ea

File tree

2 files changed

+16
-4
lines changed

2 files changed

+16
-4
lines changed

src/components/Cvv.tsx

Lines changed: 8 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -1,12 +1,18 @@
1-
import React from "react";
1+
import React, { useContext, useEffect } from "react";
22
import { StyleSheet, TextInput } from "react-native";
33

4-
import { FramesConsumer } from "../Frames";
4+
import { FramesConsumer, FramesContext } from "../Frames";
55
import { DEFAULT_CVV_PLACEHOLDER } from "../utils/constants";
66
import { CVV_CHANGE } from "../utils/actions";
77
import { FramesFieldProps } from "../types/types";
88

99
const Cvv: React.SFC<FramesFieldProps> = (props) => {
10+
const { dispatch } = useContext(FramesContext);
11+
12+
useEffect(() => {
13+
dispatch({ type: CVV_CHANGE, payload: props.value });
14+
}, [props.value]);
15+
1016
return (
1117
<FramesConsumer>
1218
{({ state, dispatch }) => {

src/components/ExpiryDate.tsx

Lines changed: 8 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -1,12 +1,18 @@
1-
import React from "react";
1+
import React, { useContext, useEffect } from "react";
22
import { StyleSheet, TextInput } from "react-native";
33

4-
import { FramesConsumer } from "../Frames";
4+
import { FramesConsumer, FramesContext } from "../Frames";
55
import { DEFAULT_CARD_EXPIRY_DATE_PLACEHOLDER } from "../utils/constants";
66
import { DATE_CHANGE } from "../utils/actions";
77
import { FramesFieldProps } from "../types/types";
88

99
const ExpiryDate: React.SFC<FramesFieldProps> = (props) => {
10+
const { dispatch } = useContext(FramesContext);
11+
12+
useEffect(() => {
13+
dispatch({ type: DATE_CHANGE, payload: props.value });
14+
}, [props.value]);
15+
1016
return (
1117
<FramesConsumer>
1218
{({ state, dispatch }) => {

0 commit comments

Comments
 (0)