In react to native
import { Appwrite } from 'appwrite';// appwrite import statement import appwriteConfig from './appwrite';// import statement
//Initializing Appwrite const appwrite = new Appwrite(); appwrite.setEndpoint(appwriteConfig.endpoint).setProject(appwriteConfig.project);
This code works in .jsx file but not working in .tsx
If i do import { Appwrite } from ‘appwrite’
It’s works in jsx file format But did not works in tsx file type
Did it give you any errors?
Do you have your tsconfig setup correctly?
import React from 'react'; import { Appwrite } from 'appwrite'; import appwriteConfig from '../src/appwrite/AppwriteConfig'; import { View, Text, Image, StyleSheet, TouchableOpacity, Linking } from 'react-native'; import Colors from '@/constants/Colors'; import { useRouter } from 'expo-router'; import welcomeImage from '../assets/images/icon.png'; const welcome_image = Image.resolveAssetSource(welcomeImage).uri;
const appwrite = new Appwrite(); appwrite.setEndpoint(appwriteConfig.endpoint).setProject(appwriteConfig.project);
const welcomeScreen = () => {
const router = useRouter();
const openPrivacyPolicy = () => {
Linking.openURL('https://quickgram.in');
};
const openTermsOfService = () => {
Linking.openURL('https://quickgram.in');
};
const handleAgreeAndContinue = () => {
router.push(./authentication/phonenumber/VerifyPhoneScreen);
};
return (
<View style={styles.container}>
<Image source={{ uri: welcome_image }} style={styles.welcome} />
<Text style={styles.headline}>Welcome to Quickgram</Text>
<Text style={styles.description}>
Read our{' '}
<Text style={styles.link} onPress={openPrivacyPolicy}>
Privacy Policy
</Text>
. {'Tap "Agree & Continue" to accept the '}
<Text style={styles.link} onPress={openTermsOfService}>
Terms of Service
</Text>
.
</Text>
<TouchableOpacity style={styles.button} onPress={handleAgreeAndContinue} >
<Text style={styles.buttonText}>Agree & Continue</Text>
</TouchableOpacity>
</View>
); };
const styles = StyleSheet.create({ container: { flex: 1, justifyContent: 'center', alignItems: 'center', padding: 20, backgroundColor: '#fff', }, welcome: { width: '80%', height: 280, borderRadius: 60, marginBottom: 80, }, headline: { fontSize: 24, fontWeight: 'bold', marginVertical: 20, }, description: { fontSize: 14, textAlign: 'center', marginBottom: 80, color: Colors.gray, }, link: { color: Colors.primary, }, button: { width: '100%', alignItems: 'center', }, buttonText: { color: Colors.primary, fontSize: 22, fontWeight: '500', }, });
export default welcomeScreen;
tsconfig
{ "extends": "expo/tsconfig.base", "compilerOptions": { "strict": true, "esModuleInterop": true, "allowSyntheticDefaultImports": true, "paths": { "@/": [ "./" ] } }, "include": [ "/*.ts", "/.tsx", ".expo/types/**/.ts", "expo-env.d.ts" , "app/index.tsx", "app/_layout.tsx" ] }
AppwriteConfig.tsx
import { Client, Account, Databases, Functions, Teams } from 'appwrite';
export const API_ENDPOINT = 'https://cloud.appwrite.io/v1' export const PROJECT_ID = 'my_project_id'
const client = new Client() .setEndpoint(API_ENDPOINT) .setProject(PROJECT_ID);
export const account = new Account(client);
export default client;
@Kenny @Moderator can you help me
i am new to appwrite
shouldn't appwriteconfig.tsx be
import { Client, Account, ID } from 'react-native-appwrite';
You are using react-native right?
Indeed appwrite do not export Appwrite, you should do import appwrite from "appwrite"
Why is your appwrite config a tsx file, should it not be a ts file?
should be a .ts file yeah
yes i am using react native
yeah i did that
Why are you doing this here
const appwrite = new Appwrite();
appwrite.setEndpoint(appwriteConfig.endpoint).setProject(appwriteConfig.project);
Is this not taken care of in your AppwriteConfig file?
I think you could benefit from reading the docs a bit more and following the getting started tutorial.
https://www.sitepoint.com/appwrite-react-user-authentication/
i am following this guide for auth
yeah
Recommended threads
- payment
I’ve never used this service. I remember signing up a long time ago but completely forgot about it. I’ve been receiving emails, but since the payments were fai...
- Problem with Google Workspace at DNS Rec...
Hello, I bought a domain at Namecheap, and Google Workspace used to work there, but now that I switched from Custom DNS to Appwrite's nameservers, it doesn't w...
- The console isnt showing documents
In console ui saved documents are being shown on frontend but i can see its showing 4 or number of docs available but in rows its only showing single doc and th...