Welcome to Code Forum!

Join a community that supports you and your coding journey from day one. We strive to be a friendly, supportive community that empowers everyone to be better developers. By registering with us, you'll be able to discuss, share and private message with other members of our community.

SignUp Now!
  • Guest, before posting your code please take these rules into consideration:
    • It is required to use our BBCode feature to display your code. While within the editor click < / > or >_ and place your code within the BB Code prompt. This helps others with finding a solution by making it easier to read and easier to copy.
    • You can also use markdown to share your code. When using markdown your code will be automatically converted to BBCode. For help with markdown check out the markdown guide.
    • Don't share a wall of code. All we want is the problem area, the code related to your issue.

    GIF shows where to locate </> in the thread and or post editor toolbar.
    To learn more about how to use our BBCode feature, review our "How to post your code into threads" here.

    Thank you, Code Forum.

JavaScript how to conert in to apk

Anurag10238i

New Coder
Code:
import React, { useState } from 'react';
import { View, Text, Button, FlatList, StyleSheet } from 'react-native';

const courses = [
  { id: '1', title: 'Computer Basics', price: 99, description: 'Learn the fundamental concepts of computer.' },
  { id: '2', title: 'Coding', price: 99, description: 'Master programming with hands-on examples.' },
  { id: '3', title: 'Hacking', price: 99, description: 'Understand cybersecurity and ethical hacking.' },
];

export default function App() {
  const [selectedCourse, setSelectedCourse] = useState(null);

  if (selectedCourse) {
    return (
      <View style={styles.container}>
        <Text style={styles.header}>{selectedCourse.title}</Text>
        <Text style={styles.text}>{selectedCourse.description}</Text>
        <Text style={styles.text}>Price: Rs. {selectedCourse.price}</Text>
        <Button title="Enroll" onPress={() => alert("Enrolled successfully!")} />
        <Button title="Back" onPress={() => setSelectedCourse(null)} />
      </View>
    );
  }

  return (
    <View style={styles.container}>
      <Text style={styles.header}>Available Courses</Text>
      <FlatList
        data={courses}
        keyExtractor={(item) => item.id}
        renderItem={({ item }) => (
          <View style={styles.item}>
            <Text style={styles.title}>{item.title}</Text>
            <Text>₹{item.price}</Text>
            <Button title="View Details" onPress={() => setSelectedCourse(item)} />
          </View>
        )}
      />
    </View>
  );
}

const styles = StyleSheet.create({
  container: { flex: 1, padding: 20, justifyContent: 'center' },
  header: { fontSize: 24, fontWeight: 'bold', marginBottom: 10 },
  title: { fontSize: 18, fontWeight: '600' },
  text: { fontSize: 16, marginVertical: 5 },
  item: { padding: 15, borderBottomWidth: 1, borderBottomColor: '#ccc' },
});
 
Last edited by a moderator:
Hey! Just to get a better idea — are you building this with React Native CLI, Expo, or something else entirely?

Also, are you looking to build the APK just to test on your phone, or are you planning to publish it on the Play Store?

Let me know a bit more about your setup — happy to point you in the right direction once I know what you're working with.
 

Buy us a coffee!

Buy me a coffee.
Back
Top Bottom