Код: Выделить всё
iOS Bundled 50ms node_modules/expo-router/entry.js (1 module)
ERROR Warning: Text strings must be rendered within a component.
8 |
9 | export default function SignInScreen() {
> 10 | const [email, setEmail] = useState('');
| ^
11 | const [password, setPassword] = useState('');
12 | const [otp, setOtp] = useState('');
13 | const [showForgotPassword, setShowForgotPassword] = useState(false);
Call Stack
SignInScreen (apps/rider_app/app/sign-in.tsx:10:37)
NavigationRoot (apps/rider_app/app/_layout.tsx:15:47)
KeyboardControllerView ()
AuthProvider (apps/rider_app/contexts/AuthContext.tsx:98:40)
RootLayout (apps/rider_app/app/_layout.tsx:41:28)
RNCSafeAreaProvider ()
App ()
ErrorOverlay ()
Код: Выделить всё
import React, { useState } from 'react';
import {
SafeAreaView,
Text,
TextInput,
TouchableOpacity,
View
} from 'react-native';
import {
KeyboardAwareScrollView,
KeyboardToolbar
} from 'react-native-keyboard-controller';
import { Colors } from 'myplatform-ui';
import { globalStyles } from 'myplatform-ui';
import { useAuth } from '@/contexts/AuthContext';
export default function SignInScreen() {
const [email, setEmail] = useState('');
const [password, setPassword] = useState('');
const [otp, setOtp] = useState('');
const [showForgotPassword, setShowForgotPassword] = useState(false);
const [resetEmail, setResetEmail] = useState('');
const {
signIn,
verifyOtp,
sendPasswordResetOTP,
authError,
setAuthError
} = useAuth();
const handleSignIn = async () => {
if (!email) {
setAuthError(new Error('Please enter a valid email'));
return;
}
if (!password) {
setAuthError(new Error('Please enter a valid password'));
return;
}
await signIn(email, password);
};
const handleOtpSignIn = async () => {
if (!email) {
setAuthError(new Error('Please enter a valid email'));
return;
}
if (!otp) {
setAuthError(new Error('Please enter a valid OTP'));
return;
}
await verifyOtp(email, otp);
};
const handleSendResetOTP = async () => {
if (!resetEmail) {
setAuthError(new Error('Please enter a valid email'));
return;
}
const { error } = await sendPasswordResetOTP(resetEmail);
if (error) {
setAuthError(error);
} else {
// Show success message
setShowForgotPassword(false);
setAuthError(
new Error('Password reset OTP sent. Please check your inbox.')
);
}
};
return (
MyPlatform Rider App
{!showForgotPassword &&
{/* Email Section */}
{
setEmail(text);
setAuthError(null);
}}
autoCapitalize="none"
keyboardType="email-address"
/>
{/* Password Section */}
Password Sign In
{
setPassword(text);
setAuthError(null);
}}
secureTextEntry
/>
Sign In
}
{/* toggle reset password view */}
{
setShowForgotPassword(!showForgotPassword);
setAuthError(null);
}}
>
{showForgotPassword
? 'Cancel Password Reset'
: 'Forgot password?'
}
{!showForgotPassword &&
{/* OTP Section */}
OTP Sign In
{
setOtp(text);
setAuthError(null);
}}
keyboardType="number-pad"
/>
Sign In via OTP
{authError && (
{authError.message || 'An unknown error occurred'}
)}
}
{/* Forgot Password Section */}
{showForgotPassword && (
Reset Password
{
setResetEmail(text);
setAuthError(null);
}}
autoCapitalize="none"
keyboardType="email-address"
/>
Send OTP
)}
{/* had to put outside of SafeAreaView for it to work:
https://github.com/kirillzyusko/react-native-keyboard-controller/issues/415
*/}
);
}
Подробнее здесь: https://stackoverflow.com/questions/797 ... onent-erro