1. Home
  2. /
  3. Nativebase
  4. /
  5. Simple Todo App

Simple Todo App - Nativebase Typing CST Test

Loading…

Simple Todo App — Nativebase Code

Demonstrates a simple React Native app using NativeBase components with a Todo list, adding tasks, and displaying them with consistent UI.

import React, { useState } from 'react';
import { NativeBaseProvider, Box, Input, Button, VStack, Text } from 'native-base';

export default function App() {
	const [todos, setTodos] = useState([]);
	const [newTodo, setNewTodo] = useState('');

	const addTodo = () => {
		if (newTodo.trim()) {
		setTodos([...todos, newTodo]);
		setNewTodo('');
		}
	};

	return (
		<NativeBaseProvider>
		<Box safeArea p={4}>
		<VStack space={4}>
		<Input placeholder="New Todo" value={newTodo} onChangeText={setNewTodo} />
		<Button onPress={addTodo}>Add</Button>
		{todos.map((todo, index) => (
		<Text key={index}>{todo}</Text>
		))}
		</VStack>
		</Box>
		</NativeBaseProvider>
	);
}

Nativebase Language Guide

NativeBase is an open-source UI component library for React Native, providing a set of cross-platform, customizable components that accelerate mobile app development with consistent design.

Primary Use Cases

  • ▸Cross-platform mobile app development
  • ▸Rapid UI prototyping
  • ▸Enterprise React Native apps
  • ▸Apps requiring consistent theming across devices
  • ▸Integration with Expo and React Native ecosystem

Notable Features

  • ▸Pre-built, customizable components
  • ▸Cross-platform support (iOS and Android)
  • ▸Themeable design system
  • ▸Flexbox-based responsive layouts
  • ▸Integration with Expo and third-party libraries

Origin & Creator

Developed by GeekyAnts, first released in 2016 to simplify React Native UI development and provide a consistent cross-platform component library.

Industrial Note

NativeBase is widely used for startups, enterprise mobile apps, and cross-platform React Native projects that need rapid prototyping and production-ready UI components.

Quick Explain

  • ▸NativeBase provides ready-to-use components like Buttons, Inputs, Modals, and more.
  • ▸It works across iOS and Android, offering a unified look and feel.
  • ▸It supports theming, responsive layouts, and integration with React Native ecosystem libraries.

Core Features

  • ▸Components: Button, Input, Modal, Toast, Avatar, etc.
  • ▸Theming: light, dark, and custom themes
  • ▸Layout system based on Flexbox
  • ▸Utility props for spacing, alignment, typography
  • ▸Support for gestures and animations via React Native APIs

Learning Path

  • ▸Learn React Native fundamentals
  • ▸Understand NativeBaseProvider and theme system
  • ▸Practice using layout components (Box, Stack, HStack, VStack)
  • ▸Use form and input components
  • ▸Integrate with navigation and state management

Practical Examples

  • ▸Login and registration forms with Input and Button
  • ▸Responsive dashboard with HStack/VStack layouts
  • ▸Themed components for dark and light mode
  • ▸Modal dialogs with forms or alerts
  • ▸List rendering with FlatList and NativeBase components

Comparisons

  • ▸Cross-platform focus vs Android-native Jetpack Compose
  • ▸Ready-to-use UI components vs building from scratch
  • ▸Works with Expo vs native-only React Native projects
  • ▸Themeable design system vs custom styling
  • ▸Faster prototyping vs fully custom UI frameworks

Strengths

  • ▸Speeds up UI development with ready-made components
  • ▸Cross-platform consistency
  • ▸Highly customizable and themeable
  • ▸Works seamlessly with React Native and Expo
  • ▸Active community and maintained library

Limitations

  • ▸Limited to React Native (no pure web support)
  • ▸Heavy reliance on third-party libraries for advanced UI
  • ▸Performance depends on React Native optimizations
  • ▸Some components may need custom styling for complex designs
  • ▸Occasional breaking changes during major version upgrades

When NOT to Use

  • ▸Pure web applications (use React + Chakra UI or Material UI)
  • ▸Projects not using React Native
  • ▸Apps with heavily custom, brand-specific UI
  • ▸Performance-critical apps requiring native code
  • ▸Projects not using JavaScript/TypeScript

Cheat Sheet

  • ▸`<NativeBaseProvider>` - top-level theme provider
  • ▸`<Box>` - basic container component
  • ▸`<Stack>` / `<HStack>` / `<VStack>` - layout components
  • ▸`<Button>` / `<Input>` - common UI elements
  • ▸`useToast()` - show toast notifications

FAQ

  • ▸Is NativeBase free?
  • ▸Yes - open-source with MIT license.
  • ▸Does it support both iOS and Android?
  • ▸Yes - fully cross-platform.
  • ▸Can I customize themes?
  • ▸Yes - supports light/dark mode and custom themes.
  • ▸Do I need React Native experience?
  • ▸Yes - NativeBase is built on React Native.
  • ▸Is NativeBase production-ready?
  • ▸Yes - widely used in real-world apps.

30-Day Skill Plan

  • ▸Week 1: Basic components (Button, Input, Box, Stack)
  • ▸Week 2: Forms and modals
  • ▸Week 3: Theming and responsive layouts
  • ▸Week 4: Integration with navigation and state
  • ▸Week 5: Advanced UI patterns and animations

Final Summary

  • ▸NativeBase is a cross-platform UI component library for React Native.
  • ▸Speeds up development with ready-to-use components.
  • ▸Supports theming, responsive layouts, and Expo integration.
  • ▸Simplifies building consistent, maintainable mobile UIs.
  • ▸Ideal for startups, enterprise apps, and rapid prototyping.

Project Structure

  • ▸App.js / index.js - entry point
  • ▸components/ - reusable NativeBase UI components
  • ▸screens/ - app screens using NativeBase
  • ▸theme/ - custom theme overrides
  • ▸utils/ - helpers and constants

Monetization

  • ▸Publish to App Store and Google Play
  • ▸Enterprise React Native apps
  • ▸Consulting and rapid prototyping services
  • ▸Reusable component library for clients
  • ▸Training teams in NativeBase best practices

Productivity Tips

  • ▸Use Expo for rapid prototyping
  • ▸Leverage built-in NativeBase components
  • ▸Customize theme for consistency
  • ▸Use Flexbox utilities for layout
  • ▸Memoize components for performance

Basic Concepts

  • ▸NativeBaseProvider: top-level provider for theme and context
  • ▸Components: building blocks for UI
  • ▸Utilities: props for spacing, color, typography
  • ▸Theming: light/dark mode and custom themes
  • ▸Responsive design: adjust layouts for different screen sizes

Official Docs

  • ▸https://nativebase.io/
  • ▸https://docs.nativebase.io/
  • ▸https://github.com/GeekyAnts/NativeBase

More Nativebase Typing Exercises

NativeBase Counter AppNativeBase Dark Mode CounterNativeBase Step CounterNativeBase Multi CounterNativeBase Auto Increment CounterNativeBase Todo With PriorityNativeBase Countdown TimerNativeBase Counter With Alert

Practice Other Languages

CReactPythonC++RustTypeScriptKotlinPHPJavaC#RubyMqlCqlN1qlCypher