fixing the size on reset
This commit is contained in:
@@ -10,8 +10,9 @@ const QRForm: React.FC = () => {
|
||||
const { state, dispatch } = useQrStore();
|
||||
const { text, size, loading } = state;
|
||||
|
||||
const callingApi = async (overrideText?: string) => {
|
||||
const callingApi = async (overrideText?: string, overrideSize?: number) => {
|
||||
const currentText = overrideText ?? text;
|
||||
const currentSize = overrideSize ?? size;
|
||||
dispatch({ type: 'setError', payload: null });
|
||||
dispatch({ type: 'setImageUrl', payload: null });
|
||||
|
||||
@@ -22,7 +23,7 @@ const QRForm: React.FC = () => {
|
||||
|
||||
dispatch({ type: 'setLoading', payload: true });
|
||||
try {
|
||||
const payload = { text: currentText, size };
|
||||
const payload = { text: currentText, size: currentSize };
|
||||
const res: GenerateResult = await generateQr(payload);
|
||||
const blobType = { type: res.mime };
|
||||
const blob = new Blob([res.data], blobType);
|
||||
@@ -56,7 +57,7 @@ const QRForm: React.FC = () => {
|
||||
|
||||
useEffect(() => {
|
||||
if (callApiOnReset) {
|
||||
callingApi(initialState.text);
|
||||
callingApi(initialState.text, initialState.size);
|
||||
setCallApiOnReset(false);
|
||||
}
|
||||
}, [callApiOnReset, callingApi]);
|
||||
|
||||
Reference in New Issue
Block a user