Stranger behavior during user login
Having an issue with login, Can anyone help with this, please?
I am building a react native app where I am creating a user account and authenticating the user via registration if the user does not exist and logs in after successfully creating a user account, so far I have a user registration screen and a login screen. I am able to create a new user but upon login, the user does not exist.

"react-native-sqlite-storage": "6.0.1",
INIT DB
useEffect(() => {
db.transaction(
txn => {
txn.executeSql(
'CREATE TABLE IF NOT EXISTS users(id INTEGER PRIMARY KEY AUTOINCREMENT, email VARCHAR(50), password VARCHAR(50))',
[],
function (tx, res) {
console.log({res});
},
);
},
e => {
console.log(e);
},
null,
);
}, []);
Register
import { openDatabase } from 'react-native-sqlite-storage';
import Button from '../../common/Button';
const db = openDatabase({name:'user.db'});
const Register = ({ navigation }) => {
const [email, setEmail] = useState('');
const [password, setPassword] = useState('');
const onRegister = useCallback(() => {
db.transaction(
(tx) => {
tx.executeSql(
'INSERT INTO users (email, password) VALUES (?,?)',
[email, password],
(tx, results) => {
console.info({'Register Results': results});
if (results.rowsAffected > 0) {
Alert.alert(
'Success',
'You are Registered Successfully',
[
{
text: 'Ok',
onPress: () => navigation.navigate('Login'),
},
],
{ cancelable: false }
);
} else alert('Registration Failed');
}
);
},
(e) => {
console.log(e);
},
null
);
}, []);
LOGIN
import {openDatabase} from 'react-native-sqlite-storage';
import Button from './../../common/Button';
const db = openDatabase({name: 'user.db'});
const Login = ({navigation}) => {
const dispatch = useDispatch();
const [email, setEmail] = useState('');
const [password, setPassword] = useState('');
const onLogin = () => {
if (email === '' || password === '') {
alert('Please enter your username and password!');
return;
}
db.transaction(
tx => {
tx.executeSql(
'SELECT * FROM users WHERE email= ?',
[email],
(tx, results) => {
console.info({outside: results});
if (results.rows.length === 0) {
Alert.alert('User does not exist!');
} else {
console.info({results});
const row = results.rows.item;
if (password === row.password) {
navigation.navigate('Home');
dispatch(authed(results.rows));
return;
}
Alert.alert('Authentication failed!');
}
},
);
},
e => {
Alert.alert(
'Error',
'Login failed ' + e.message,
[
{
text: 'Ok',
},
],
{cancelable: false},
);
},
);
};
Still need help with this
What platform are you running this on?
Also, should
'SELECT * FROM users WHERE email= ?'
be
`SELECT * FROM users WHERE email= ${email}`?