Author: saqibkhan

  • CodeCompass

    Setting Up Your Environment

    If you haven’t set up a React project yet, you can use Create React App:

    bashCopy codenpx create-react-app code-compass
    cd code-compass
    

    Step 2: Create Basic Components

    We’ll create two main components: ProjectList and AddProject.

    1. Create ProjectList.js

    In the src folder, create a new file called ProjectList.js:

    jsxCopy code// src/ProjectList.js
    import React from 'react';
    
    const ProjectList = ({ projects, onDelete }) => {
      return (
    
    <ul>
      {projects.map((project, index) => (
        <li key={index}>
          {project.name} - {project.description}
          <button onClick={() => onDelete(index)}>Delete</button>
        </li>
      ))}
    </ul>
    ); }; export default ProjectList;

    2. Create AddProject.js

    Now create another file called AddProject.js:

    jsxCopy code// src/AddProject.js
    import React, { useState } from 'react';
    
    const AddProject = ({ onAdd }) => {
      const [name, setName] = useState('');
      const [description, setDescription] = useState('');
    
      const handleSubmit = (e) => {
    
    e.preventDefault();
    if (name && description) {
      onAdd({ name, description });
      setName('');
      setDescription('');
    }
    }; return (
    <form onSubmit={handleSubmit}>
      <input
        type="text"
        value={name}
        onChange={(e) => setName(e.target.value)}
        placeholder="Project Name"
      />
      <input
        type="text"
        value={description}
        onChange={(e) => setDescription(e.target.value)}
        placeholder="Project Description"
      />
      <button type="submit">Add Project</button>
    </form>
    ); }; export default AddProject;

    Step 3: Main Application Component

    Now, let’s integrate everything in App.js.

    jsxCopy code// src/App.js
    import React, { useState } from 'react';
    import ProjectList from './ProjectList';
    import AddProject from './AddProject';
    
    const App = () => {
      const [projects, setProjects] = useState([]);
    
      const addProject = (project) => {
    
    setProjects([...projects, project]);
    }; const deleteProject = (index) => {
    const newProjects = projects.filter((_, i) => i !== index);
    setProjects(newProjects);
    }; return (
    <div>
      <h1>CodeCompass: Project Manager</h1>
      <AddProject onAdd={addProject} />
      <ProjectList projects={projects} onDelete={deleteProject} />
    </div>
    ); }; export default App;

    Step 4: Run Your Application

    Now you can start your application. In your terminal, run:

    bashCopy codenpm start
    

    Step 5: Explore and Enhance

    You now have a basic React application called “CodeCompass” that allows you to manage a list of coding projects. You can enhance it by adding features like:

    • Editing project details
    • Filtering projects by category or status
    • Persisting project data in local storage

    Summary

    In this tutorial, you created a simple project manager app using React. You learned how to manage state, create reusable components, and handle user interactions.

  • ReactRealm

    Setting Up Your Environment

    1. Create a New React AppUse Create React App to set up your project:bashCopy codenpx create-react-app react-realm cd react-realm
    2. Install RealmYou’ll need to install the Realm database package:bashCopy codenpm install realm

    Step 2: Create the Realm Schema

    First, we need to define our data model. Create a new file called Book.js in the src folder to define the Realm schema:

    javascriptCopy code// src/Book.js
    import Realm from 'realm';
    
    class Book {
      static schema = {
    
    name: 'Book',
    properties: {
      id: 'int',
      title: 'string',
      author: 'string',
    },
    primaryKey: 'id',
    }; } export default Book;

    Step 3: Create Basic Components

    We’ll create two main components: BookList and AddBook.

    1. Create BookList.js

    In the src folder, create a new file called BookList.js:

    javascriptCopy code// src/BookList.js
    import React from 'react';
    import { View, Text, FlatList, StyleSheet, Button } from 'react-native';
    
    const BookList = ({ books, onDelete }) => {
      return (
    
    <FlatList
      data={books}
      keyExtractor={(item) => item.id.toString()}
      renderItem={({ item }) => (
        <View style={styles.itemContainer}>
          <Text style={styles.itemText}>
            {item.title} by {item.author}
          </Text>
          <Button title="Delete" onPress={() => onDelete(item.id)} />
        </View>
      )}
    />
    ); }; const styles = StyleSheet.create({ itemContainer: {
    padding: 15,
    flexDirection: 'row',
    justifyContent: 'space-between',
    alignItems: 'center',
    borderBottomWidth: 1,
    borderBottomColor: '#ccc',
    }, itemText: {
    fontSize: 18,
    }, }); export default BookList;

    2. Create AddBook.js

    Now create another file called AddBook.js:

    javascriptCopy code// src/AddBook.js
    import React, { useState } from 'react';
    import { View, TextInput, Button, StyleSheet } from 'react-native';
    
    const AddBook = ({ onAdd }) => {
      const [title, setTitle] = useState('');
      const [author, setAuthor] = useState('');
    
      const handleSubmit = () => {
    
    if (title && author) {
      onAdd({ title, author });
      setTitle('');
      setAuthor('');
    }
    }; return (
    <View style={styles.container}>
      <TextInput
        style={styles.input}
        placeholder="Book Title"
        value={title}
        onChangeText={setTitle}
      />
      <TextInput
        style={styles.input}
        placeholder="Author"
        value={author}
        onChangeText={setAuthor}
      />
      <Button title="Add Book" onPress={handleSubmit} />
    </View>
    ); }; const styles = StyleSheet.create({ container: {
    marginBottom: 20,
    }, input: {
    borderWidth: 1,
    borderColor: '#ccc',
    padding: 10,
    marginBottom: 10,
    }, }); export default AddBook;

    Step 4: Main Application Component

    Now, let’s integrate everything in App.js.

    javascriptCopy code// src/App.js
    import React, { useState, useEffect } from 'react';
    import { View, Text, StyleSheet } from 'react-native';
    import Realm from 'realm';
    import Book from './Book';
    import BookList from './BookList';
    import AddBook from './AddBook';
    
    const App = () => {
      const [books, setBooks] = useState([]);
      const realm = new Realm({ schema: [Book] });
    
      useEffect(() => {
    
    const loadBooks = () => {
      const storedBooks = realm.objects('Book');
      setBooks(Array.from(storedBooks));
    };
    loadBooks();
    }, []); const addBook = ({ title, author }) => {
    realm.write(() => {
      const newBook = realm.create('Book', {
        id: realm.objects('Book').length + 1,
        title,
        author,
      });
      setBooks((prevBooks) => [...prevBooks, newBook]);
    });
    }; const deleteBook = (id) => {
    realm.write(() => {
      const bookToDelete = realm.objectForPrimaryKey('Book', id);
      if (bookToDelete) {
        realm.delete(bookToDelete);
        setBooks((prevBooks) => prevBooks.filter((book) => book.id !== id));
      }
    });
    }; return (
    <View style={styles.container}>
      <Text style={styles.title}>ReactRealm: Book Manager</Text>
      <AddBook onAdd={addBook} />
      <BookList books={books} onDelete={deleteBook} />
    </View>
    ); }; const styles = StyleSheet.create({ container: {
    flex: 1,
    padding: 20,
    backgroundColor: '#fff',
    }, title: {
    fontSize: 24,
    fontWeight: 'bold',
    marginBottom: 20,
    }, }); export default App;

    Step 5: Run Your Application

    Now you can start your application. In your terminal, run:

    bashCopy codenpm start
    

    This command will open a new tab in your browser, allowing you to run the app on an emulator or your physical device using Expo Go app.

    Summary

    In this tutorial, you created a simple book manager app using Realm for data persistence. You learned how to manage state, create reusable components, and interact with a local database.

    Feel free to enhance the application with additional features, such as:

    • Editing book details
    • Searching for books
    • Adding categories or tags
  • Nativator

    Setting Up Your Environment

    Make sure you have Node.js and npm installed. We will use Expo for easy React Native development.

    1. Install Expo CLI if you haven’t already:bashCopy codenpm install -g expo-cli
    2. Create a new project:bashCopy codeexpo init Nativator cd Nativator
    3. Choose the “blank” template when prompted.

    Step 2: Create Basic Components

    We will create two main components: PlantList and AddPlant.

    1. Create PlantList.js

    In the components folder (create it if it doesn’t exist), create a new file called PlantList.js:

    jsxCopy code// components/PlantList.js
    import React from 'react';
    import { View, Text, FlatList, StyleSheet, Button } from 'react-native';
    
    const PlantList = ({ plants, onDelete }) => {
      return (
    
    <FlatList
      data={plants}
      keyExtractor={(item, index) => index.toString()}
      renderItem={({ item, index }) => (
        <View style={styles.itemContainer}>
          <Text style={styles.itemText}>{item}</Text>
          <Button title="Delete" onPress={() => onDelete(index)} />
        </View>
      )}
    />
    ); }; const styles = StyleSheet.create({ itemContainer: {
    padding: 15,
    flexDirection: 'row',
    justifyContent: 'space-between',
    alignItems: 'center',
    borderBottomWidth: 1,
    borderBottomColor: '#ccc',
    }, itemText: {
    fontSize: 18,
    }, }); export default PlantList;

    2. Create AddPlant.js

    Now create another file called AddPlant.js:

    jsxCopy code// components/AddPlant.js
    import React, { useState } from 'react';
    import { View, TextInput, Button, StyleSheet } from 'react-native';
    
    const AddPlant = ({ onAdd }) => {
      const [inputValue, setInputValue] = useState('');
    
      const handleSubmit = () => {
    
    if (inputValue) {
      onAdd(inputValue);
      setInputValue('');
    }
    }; return (
    <View style={styles.container}>
      <TextInput
        style={styles.input}
        placeholder="Add a new native plant"
        value={inputValue}
        onChangeText={setInputValue}
      />
      <Button title="Add" onPress={handleSubmit} />
    </View>
    ); }; const styles = StyleSheet.create({ container: {
    flexDirection: 'row',
    marginVertical: 20,
    }, input: {
    borderWidth: 1,
    borderColor: '#ccc',
    flex: 1,
    padding: 10,
    marginRight: 10,
    }, }); export default AddPlant;

    Step 3: Main Application Component

    Now, let’s integrate everything in App.js.

    jsxCopy code// App.js
    import React, { useState } from 'react';
    import { View, Text, StyleSheet } from 'react-native';
    import PlantList from './components/PlantList';
    import AddPlant from './components/AddPlant';
    
    const App = () => {
      const [plants, setPlants] = useState([]);
    
      const addPlant = (plant) => {
    
    setPlants([...plants, plant]);
    }; const deletePlant = (index) => {
    const newPlants = plants.filter((_, i) => i !== index);
    setPlants(newPlants);
    }; return (
    <View style={styles.container}>
      <Text style={styles.title}>Nativator: Native Plant Manager</Text>
      <AddPlant onAdd={addPlant} />
      <PlantList plants={plants} onDelete={deletePlant} />
    </View>
    ); }; const styles = StyleSheet.create({ container: {
    flex: 1,
    padding: 20,
    backgroundColor: '#fff',
    }, title: {
    fontSize: 24,
    fontWeight: 'bold',
    marginBottom: 20,
    }, }); export default App;

    Step 4: Run Your Application

    Now you can start your application. In your terminal, run:

    bashCopy codeexpo start
    

    This command will open a new tab in your browser, allowing you to run the app on an emulator or your physical device using the Expo Go app.

    Step 5: Explore and Enhance

    You now have a basic React Native application called “Nativator” that allows you to manage a list of native plants. You can enhance it by adding features like:

    • Editing plant names
    • Categorizing plants by type
    • Storing plants in local storage for persistence

    Summary

    In this tutorial, you created a simple plant manager app with React Native. You learned how to manage state, create reusable components, and handle user interactions.

  • PixelPioneer

    Setting Up Your Environment

    If you haven’t set up a React project yet, you can use Create React App:

    bashCopy codenpx create-react-app pixel-pioneer
    cd pixel-pioneer
    

    Step 2: Create Basic Components

    We will create two main components: ArtList and AddArt.

    1. Create ArtList.js

    In the src folder, create a new file called ArtList.js:

    jsxCopy code// src/ArtList.js
    import React from 'react';
    
    const ArtList = ({ artProjects, onDelete }) => {
      return (
    
    <ul>
      {artProjects.map((art, index) => (
        <li key={index}>
          {art}
          <button onClick={() => onDelete(index)}>Delete</button>
        </li>
      ))}
    </ul>
    ); }; export default ArtList;

    2. Create AddArt.js

    Now create another file called AddArt.js:

    jsxCopy code// src/AddArt.js
    import React, { useState } from 'react';
    
    const AddArt = ({ onAdd }) => {
      const [inputValue, setInputValue] = useState('');
    
      const handleSubmit = (e) => {
    
    e.preventDefault();
    if (inputValue) {
      onAdd(inputValue);
      setInputValue('');
    }
    }; return (
    <form onSubmit={handleSubmit}>
      <input
        type="text"
        value={inputValue}
        onChange={(e) => setInputValue(e.target.value)}
        placeholder="Add a new pixel art project"
      />
      <button type="submit">Add</button>
    </form>
    ); }; export default AddArt;

    Step 3: Main Application Component

    Now, let’s integrate everything in App.js.

    jsxCopy code// src/App.js
    import React, { useState } from 'react';
    import ArtList from './ArtList';
    import AddArt from './AddArt';
    
    const App = () => {
      const [artProjects, setArtProjects] = useState([]);
    
      const addArt = (art) => {
    
    setArtProjects([...artProjects, art]);
    }; const deleteArt = (index) => {
    const newArtProjects = artProjects.filter((_, i) => i !== index);
    setArtProjects(newArtProjects);
    }; return (
    <div>
      <h1>PixelPioneer: Pixel Art Manager</h1>
      <AddArt onAdd={addArt} />
      <ArtList artProjects={artProjects} onDelete={deleteArt} />
    </div>
    ); }; export default App;

    Step 4: Run Your Application

    Now you can start your application. In your terminal, run:

    bashCopy codenpm start
    

    Step 5: Explore and Enhance

    You now have a basic React application called “PixelPioneer” that allows you to manage a list of pixel art projects. You can enhance it by adding features like:

    • Editing art project names
    • Adding categories or tags for each project
    • Storing projects in local storage for persistence

    Summary

    In this tutorial, you created a simple project manager app for pixel art with React. You learned how to manage state, create reusable components, and handle user interactions.

  • AppSynergy

    Setting Up Your Environment

    If you haven’t set up a React project yet, you can use Create React App:

    bashCopy codenpx create-react-app app-synergy
    cd app-synergy
    

    Step 2: Create Basic Components

    We will create two main components: TaskList and AddTask.

    1. Create TaskList.js

    In the src folder, create a new file called TaskList.js:

    jsxCopy code// src/TaskList.js
    import React from 'react';
    
    const TaskList = ({ tasks, onDelete }) => {
      return (
    
    <ul>
      {tasks.map((task, index) => (
        <li key={index}>
          {task}
          <button onClick={() => onDelete(index)}>Delete</button>
        </li>
      ))}
    </ul>
    ); }; export default TaskList;

    2. Create AddTask.js

    Now create another file called AddTask.js:

    jsxCopy code// src/AddTask.js
    import React, { useState } from 'react';
    
    const AddTask = ({ onAdd }) => {
      const [inputValue, setInputValue] = useState('');
    
      const handleSubmit = (e) => {
    
    e.preventDefault();
    if (inputValue) {
      onAdd(inputValue);
      setInputValue('');
    }
    }; return (
    <form onSubmit={handleSubmit}>
      <input
        type="text"
        value={inputValue}
        onChange={(e) => setInputValue(e.target.value)}
        placeholder="Add a new task"
      />
      <button type="submit">Add</button>
    </form>
    ); }; export default AddTask;

    Step 3: Main Application Component

    Now, let’s integrate everything in App.js.

    jsxCopy code// src/App.js
    import React, { useState } from 'react';
    import TaskList from './TaskList';
    import AddTask from './AddTask';
    
    const App = () => {
      const [tasks, setTasks] = useState([]);
    
      const addTask = (task) => {
    
    setTasks([...tasks, task]);
    }; const deleteTask = (index) => {
    const newTasks = tasks.filter((_, i) => i !== index);
    setTasks(newTasks);
    }; return (
    <div>
      <h1>AppSynergy: Task Manager</h1>
      <AddTask onAdd={addTask} />
      <TaskList tasks={tasks} onDelete={deleteTask} />
    </div>
    ); }; export default App;

    Step 4: Run Your Application

    Now you can start your application. In your terminal, run:

    bashCopy codenpm start
    

    Step 5: Explore and Enhance

    You now have a basic React application called “AppSynergy” that allows you to manage a list of tasks. You can enhance it by adding features like:

    • Editing tasks
    • Marking tasks as complete
    • Storing tasks in local storage for persistence

    Summary

    In this tutorial, you created a simple task manager app with React. You learned how to manage state, create reusable components, and handle user interactions.

  • CrossPlatformer

    Setting Up Your Environment

    Make sure you have Node.js and npm installed. We’ll use Expo for easy cross-platform development.

    1. Install Expo CLI if you haven’t already:bashCopy codenpm install -g expo-cli
    2. Create a new project:bashCopy codeexpo init CrossPlatformer cd CrossPlatformer
    3. Choose the “blank” template when prompted.

    Step 2: Create Basic Components

    We will create two main components: HobbyList and AddHobby.

    1. Create HobbyList.js

    In the components folder (create it if it doesn’t exist), create a new file called HobbyList.js:

    jsxCopy code// components/HobbyList.js
    import React from 'react';
    import { View, Text, FlatList, StyleSheet, Button } from 'react-native';
    
    const HobbyList = ({ hobbies, onDelete }) => {
      return (
    
    <FlatList
      data={hobbies}
      keyExtractor={(item, index) => index.toString()}
      renderItem={({ item, index }) => (
        <View style={styles.itemContainer}>
          <Text style={styles.itemText}>{item}</Text>
          <Button title="Delete" onPress={() => onDelete(index)} />
        </View>
      )}
    />
    ); }; const styles = StyleSheet.create({ itemContainer: {
    padding: 15,
    flexDirection: 'row',
    justifyContent: 'space-between',
    alignItems: 'center',
    borderBottomWidth: 1,
    borderBottomColor: '#ccc',
    }, itemText: {
    fontSize: 18,
    }, }); export default HobbyList;

    2. Create AddHobby.js

    Now create another file called AddHobby.js:

    jsxCopy code// components/AddHobby.js
    import React, { useState } from 'react';
    import { View, TextInput, Button, StyleSheet } from 'react-native';
    
    const AddHobby = ({ onAdd }) => {
      const [inputValue, setInputValue] = useState('');
    
      const handleSubmit = () => {
    
    if (inputValue) {
      onAdd(inputValue);
      setInputValue('');
    }
    }; return (
    <View style={styles.container}>
      <TextInput
        style={styles.input}
        placeholder="Add a new hobby"
        value={inputValue}
        onChangeText={setInputValue}
      />
      <Button title="Add" onPress={handleSubmit} />
    </View>
    ); }; const styles = StyleSheet.create({ container: {
    flexDirection: 'row',
    marginVertical: 20,
    }, input: {
    borderWidth: 1,
    borderColor: '#ccc',
    flex: 1,
    padding: 10,
    marginRight: 10,
    }, }); export default AddHobby;

    Step 3: Main Application Component

    Now, let’s integrate everything in App.js.

    jsxCopy code// App.js
    import React, { useState } from 'react';
    import { View, Text, StyleSheet } from 'react-native';
    import HobbyList from './components/HobbyList';
    import AddHobby from './components/AddHobby';
    
    const App = () => {
      const [hobbies, setHobbies] = useState([]);
    
      const addHobby = (hobby) => {
    
    setHobbies([...hobbies, hobby]);
    }; const deleteHobby = (index) => {
    const newHobbies = hobbies.filter((_, i) => i !== index);
    setHobbies(newHobbies);
    }; return (
    <View style={styles.container}>
      <Text style={styles.title}>CrossPlatformer: Hobby Manager</Text>
      <AddHobby onAdd={addHobby} />
      <HobbyList hobbies={hobbies} onDelete={deleteHobby} />
    </View>
    ); }; const styles = StyleSheet.create({ container: {
    flex: 1,
    padding: 20,
    backgroundColor: '#fff',
    }, title: {
    fontSize: 24,
    fontWeight: 'bold',
    marginBottom: 20,
    }, }); export default App;

    Step 4: Run Your Application

    Start your application using:

    bashCopy codeexpo start
    

    This command will open a new tab in your browser, allowing you to run the app on an emulator or your physical device using the Expo Go app. You can also run it on the web by selecting the web option in the Expo interface.

    Summary

    In this tutorial, you created a simple cross-platform app called “CrossPlatformer” that allows users to manage a list of hobbies. You learned how to handle state, create reusable components, and work with React Native, which can be run on both mobile and web.

    Feel free to enhance the application with features like:

    • Editing hobbies
    • Persisting data using AsyncStorage
    • Adding categories for hobbies
  • ReactRoot

    Setting Up Your Environment

    If you haven’t set up a React project yet, you can use Create React App:

    bashCopy codenpx create-react-app react-root
    cd react-root
    

    Step 2: Create Basic Components

    We will create two main components: TaskList and AddTask.

    1. Create TaskList.js

    In the src folder, create a new file called TaskList.js:

    jsxCopy code// src/TaskList.js
    import React from 'react';
    
    const TaskList = ({ tasks, onDelete }) => {
      return (
    
    <ul>
      {tasks.map((task, index) => (
        <li key={index}>
          {task}
          <button onClick={() => onDelete(index)}>Delete</button>
        </li>
      ))}
    </ul>
    ); }; export default TaskList;

    2. Create AddTask.js

    Now create another file called AddTask.js:

    jsxCopy code// src/AddTask.js
    import React, { useState } from 'react';
    
    const AddTask = ({ onAdd }) => {
      const [inputValue, setInputValue] = useState('');
    
      const handleSubmit = (e) => {
    
    e.preventDefault();
    if (inputValue) {
      onAdd(inputValue);
      setInputValue('');
    }
    }; return (
    <form onSubmit={handleSubmit}>
      <input
        type="text"
        value={inputValue}
        onChange={(e) => setInputValue(e.target.value)}
        placeholder="Add a new task"
      />
      <button type="submit">Add</button>
    </form>
    ); }; export default AddTask;

    Step 3: Main Application Component

    Now, let’s integrate everything in App.js.

    jsxCopy code// src/App.js
    import React, { useState } from 'react';
    import TaskList from './TaskList';
    import AddTask from './AddTask';
    
    const App = () => {
      const [tasks, setTasks] = useState([]);
    
      const addTask = (task) => {
    
    setTasks([...tasks, task]);
    }; const deleteTask = (index) => {
    const newTasks = tasks.filter((_, i) => i !== index);
    setTasks(newTasks);
    }; return (
    <div>
      <h1>ReactRoot: Task Manager</h1>
      <AddTask onAdd={addTask} />
      <TaskList tasks={tasks} onDelete={deleteTask} />
    </div>
    ); }; export default App;

    Step 4: Run Your Application

    Now you can start your application. In your terminal, run:

    bashCopy codenpm start
    

    Step 5: Explore and Enhance

    You now have a basic React application called “ReactRoot” that allows you to manage a list of tasks. You can enhance it by adding features like:

    • Editing tasks
    • Marking tasks as complete
    • Persisting tasks in local storage

    Summary

    In this tutorial, you created a simple task manager app with React. You learned how to manage state, create reusable components, and handle user interactions.

  • MobileMuse

    Setting Up Your Environment

    Make sure you have Node.js and npm installed. We will use Expo to create our React Native app.

    1. Install Expo CLI if you haven’t already:bashCopy codenpm install -g expo-cli
    2. Create a new project:bashCopy codeexpo init MobileMuse cd MobileMuse
    3. Choose a blank template when prompted.

    Step 2: Create Basic Components

    We’ll create two main components: IdeaList and AddIdea.

    1. Create IdeaList.js

    In the components folder (create it if it doesn’t exist), create a new file called IdeaList.js:

    jsxCopy code// components/IdeaList.js
    import React from 'react';
    import { View, Text, FlatList, StyleSheet } from 'react-native';
    
    const IdeaList = ({ ideas }) => {
      return (
    
    <FlatList
      data={ideas}
      keyExtractor={(item, index) => index.toString()}
      renderItem={({ item }) => (
        <View style={styles.itemContainer}>
          <Text style={styles.itemText}>{item}</Text>
        </View>
      )}
    />
    ); }; const styles = StyleSheet.create({ itemContainer: {
    padding: 15,
    borderBottomWidth: 1,
    borderBottomColor: '#ccc',
    }, itemText: {
    fontSize: 18,
    }, }); export default IdeaList;

    2. Create AddIdea.js

    Now create another file called AddIdea.js:

    jsxCopy code// components/AddIdea.js
    import React, { useState } from 'react';
    import { View, TextInput, Button, StyleSheet } from 'react-native';
    
    const AddIdea = ({ onAdd }) => {
      const [inputValue, setInputValue] = useState('');
    
      const handleSubmit = () => {
    
    if (inputValue) {
      onAdd(inputValue);
      setInputValue('');
    }
    }; return (
    <View style={styles.container}>
      <TextInput
        style={styles.input}
        placeholder="Add a new idea"
        value={inputValue}
        onChangeText={setInputValue}
      />
      <Button title="Add" onPress={handleSubmit} />
    </View>
    ); }; const styles = StyleSheet.create({ container: {
    flexDirection: 'row',
    marginVertical: 20,
    }, input: {
    borderWidth: 1,
    borderColor: '#ccc',
    flex: 1,
    padding: 10,
    marginRight: 10,
    }, }); export default AddIdea;

    Step 3: Main Application Component

    Now, let’s integrate everything in App.js.

    jsxCopy code// App.js
    import React, { useState } from 'react';
    import { View, Text, StyleSheet } from 'react-native';
    import IdeaList from './components/IdeaList';
    import AddIdea from './components/AddIdea';
    
    const App = () => {
      const [ideas, setIdeas] = useState([]);
    
      const addIdea = (idea) => {
    
    setIdeas([...ideas, idea]);
    }; return (
    <View style={styles.container}>
      <Text style={styles.title}>MobileMuse: Idea Manager</Text>
      <AddIdea onAdd={addIdea} />
      <IdeaList ideas={ideas} />
    </View>
    ); }; const styles = StyleSheet.create({ container: {
    flex: 1,
    padding: 20,
    backgroundColor: '#fff',
    }, title: {
    fontSize: 24,
    fontWeight: 'bold',
    marginBottom: 20,
    }, }); export default App;

    Step 4: Run Your Application

    Start your application using:

    bashCopy codeexpo start
    

    This command will open a new tab in your browser, allowing you to run the app on an emulator or your physical device using the Expo Go app.

    Summary

    In this tutorial, you created a simple React Native app called “MobileMuse” that allows users to add and manage creative ideas. You learned how to manage state and create reusable components in React Native.

    Feel free to enhance the application by adding features like:

    • Removing ideas
    • Editing ideas
    • Storing data with AsyncStorage for persistence
  • Reactify

    Setting Up Your Environment

    If you haven’t set up a React project yet, you can use Create React App:

    bashCopy codenpx create-react-app reactify
    cd reactify
    

    Step 2: Create Basic Components

    We’ll create two main components: SongList and AddSong.

    1. Create SongList.js

    In the src folder, create a new file called SongList.js:

    jsxCopy code// src/SongList.js
    import React from 'react';
    
    const SongList = ({ songs }) => {
      return (
    
    <ul>
      {songs.map((song, index) => (
        <li key={index}>{song}</li>
      ))}
    </ul>
    ); }; export default SongList;

    2. Create AddSong.js

    Now create another file called AddSong.js:

    jsxCopy code// src/AddSong.js
    import React, { useState } from 'react';
    
    const AddSong = ({ onAdd }) => {
      const [inputValue, setInputValue] = useState('');
    
      const handleSubmit = (e) => {
    
    e.preventDefault();
    if (inputValue) {
      onAdd(inputValue);
      setInputValue('');
    }
    }; return (
    <form onSubmit={handleSubmit}>
      <input
        type="text"
        value={inputValue}
        onChange={(e) => setInputValue(e.target.value)}
        placeholder="Add a new song"
      />
      <button type="submit">Add</button>
    </form>
    ); }; export default AddSong;

    Step 3: Main Application Component

    Now, let’s tie everything together in App.js.

    jsxCopy code// src/App.js
    import React, { useState } from 'react';
    import SongList from './SongList';
    import AddSong from './AddSong';
    
    const App = () => {
      const [songs, setSongs] = useState([]);
    
      const addSong = (song) => {
    
    setSongs([...songs, song]);
    }; return (
    <div>
      <h1>My Playlist</h1>
      <AddSong onAdd={addSong} />
      <SongList songs={songs} />
    </div>
    ); }; export default App;

    Step 4: Run Your Application

    Now you can start your application. In your terminal, run:

    bashCopy codenpm start
    

    Step 5: Explore and Enhance

    You now have a basic React application that allows you to add songs to a playlist. You can enhance it by adding features like:

    • Removing songs
    • Persisting the playlist to local storage
    • Adding additional song details (artist, album)

    Summary

    This tutorial walked you through creating a simple React application with a playlist feature. You learned how to manage state and create reusable components in React.

  • Nativify

    Setting Up Your Environment

    Make sure you have Node.js and npm installed. You can create a new React Native project using Expo:

    1. Install Expo CLI if you haven’t already:bashCopy codenpm install -g expo-cli
    2. Create a new project:bashCopy codeexpo init nativify-app cd nativify-app
    3. Choose a blank template when prompted.

    Step 2: Create Basic Components

    We’ll create two main components: ItemList and AddItem.

    1. Create ItemList.js

    In the components folder (create it if it doesn’t exist), create a new file called ItemList.js:

    jsxCopy code// components/ItemList.js
    import React from 'react';
    import { View, Text, FlatList, StyleSheet } from 'react-native';
    
    const ItemList = ({ items }) => {
      return (
    
    <FlatList
      data={items}
      keyExtractor={(item, index) => index.toString()}
      renderItem={({ item }) => (
        <View style={styles.itemContainer}>
          <Text style={styles.itemText}>{item}</Text>
        </View>
      )}
    />
    ); }; const styles = StyleSheet.create({ itemContainer: {
    padding: 15,
    borderBottomWidth: 1,
    borderBottomColor: '#ccc',
    }, itemText: {
    fontSize: 18,
    }, }); export default ItemList;

    2. Create AddItem.js

    Now create another file called AddItem.js:

    jsxCopy code// components/AddItem.js
    import React, { useState } from 'react';
    import { View, TextInput, Button, StyleSheet } from 'react-native';
    
    const AddItem = ({ onAdd }) => {
      const [inputValue, setInputValue] = useState('');
    
      const handleSubmit = () => {
    
    if (inputValue) {
      onAdd(inputValue);
      setInputValue('');
    }
    }; return (
    <View style={styles.container}>
      <TextInput
        style={styles.input}
        placeholder="Add new item"
        value={inputValue}
        onChangeText={setInputValue}
      />
      <Button title="Add" onPress={handleSubmit} />
    </View>
    ); }; const styles = StyleSheet.create({ container: {
    flexDirection: 'row',
    marginVertical: 20,
    }, input: {
    borderWidth: 1,
    borderColor: '#ccc',
    flex: 1,
    padding: 10,
    marginRight: 10,
    }, }); export default AddItem;

    Step 3: Main Application Component

    Now, let’s integrate everything in App.js.

    jsxCopy code// App.js
    import React, { useState } from 'react';
    import { View, Text, StyleSheet } from 'react-native';
    import ItemList from './components/ItemList';
    import AddItem from './components/AddItem';
    
    const App = () => {
      const [items, setItems] = useState([]);
    
      const addItem = (item) => {
    
    setItems([...items, item]);
    }; return (
    <View style={styles.container}>
      <Text style={styles.title}>Nativify Item List</Text>
      <AddItem onAdd={addItem} />
      <ItemList items={items} />
    </View>
    ); }; const styles = StyleSheet.create({ container: {
    flex: 1,
    padding: 20,
    backgroundColor: '#fff',
    }, title: {
    fontSize: 24,
    fontWeight: 'bold',
    marginBottom: 20,
    }, }); export default App;

    Step 4: Run Your Application

    Start your application using:

    bashCopy codeexpo start
    

    This command will open a new tab in your browser, allowing you to run the app on an emulator or your physical device using the Expo Go app.

    Summary

    In this tutorial, you created a simple React Native app that allows users to add items to a list. You learned how to manage state and create reusable components in React Native.

    You can enhance the application by adding features like:

    • Removing items
    • Editing items
    • Storing data with AsyncStorage