10000 GitHub - Linal180/react-template-with-ts: This project demonstrates advanced concepts in React, including global state management, hooks, custom hooks, lazy loading, and best practices for code reusability and app structure. It is designed to showcase efficient use of React’s core utilities, ensuring an optimized and scalable application.
[go: up one dir, main page]
More Web Proxy on the site http://driver.im/
Skip to content

This project demonstrates advanced concepts in React, including global state management, hooks, custom hooks, lazy loading, and best practices for code reusability and app structure. It is designed to showcase efficient use of React’s core utilities, ensuring an optimized and scalable application.

Notifications You must be signed in to change notification settings

Linal180/react-template-with-ts

Repository files navigation

React + TypeScript + Vite

This template provides a minimal setup to get React working in Vite with Hot Module Replacement (HMR) and includes some ESLint rules for code quality.

Plugins

Currently, two official plugins are available:

Expanding the ESLint Configuration

For production-level applications, it’s recommended to enhance the ESLint configuration to enable type-aware linting rules.

Steps:

  1. Configure the top-level parserOptions property as follows:

    export default tseslint.config({
      languageOptions: {
        // other options...
        parserOptions: {
          project: ['./tsconfig.node.json', './tsconfig.app.json'],
          tsconfigRootDir: import.meta.dirname,
        },
      },
    })
  2. Replace tseslint.configs.recommended with either:

    • tseslint.configs.recommendedTypeChecked
    • tseslint.configs.strictTypeChecked
  3. Optionally, add ...tseslint.configs.stylisticTypeChecked for style-based lint rules.

  4. Install eslint-plugin-react and update the ESLint configuration:

    // eslint.config.js
    import react from 'eslint-plugin-react';
    
    export default tseslint.config({
      // Set the React version
      settings: { react: { version: '18.3' } },
      plugins: {
        // Add the react plugin
        react,
      },
      rules: {
        // other rules...
        // Enable its recommended rules
        ...react.configs.recommended.rules,
        ...react.configs['jsx-runtime'].rules,
      },
    });

Features

  • User-friendly interface for task management.
  • Global state management using React Context API.
  • Form handling with React Hook Form and validation via Yup.
  • Responsive design with Material UI.
  • Optimized performance with lazy loading of components.

Global State Management

The application uses the React Context API for global state management, allowing for centralized state management and easy sharing of state across components.

Hooks and Custom Hooks

Custom hooks are utilized to encapsulate logic and state management, enhancing code reusability. Key hooks include:

  • useTasks: A custom hook for managing task-related state and actions.

Lazy Loading

Lazy loading is implemented to improve performance by loading components only when needed, enhancing the user experience.

Best Practices

Code Reusability

  • Use custom hooks to encapsulate common logic and avoid duplication.
  • Favor component composition over inheritance.

App Structure

  • Organize your project by feature or functionality.
  • Maintain consistent naming conventions for better readability.

Installation

To get started with the project, clone the repository and install the dependencies:

git clone https://github.com/AdeelKamalMalik/react-template.git
cd react-template
npm install

Running the Project

After installing the dependencies, you can start the development server with the following command:

npm run dev

Open your browser and navigate to http://localhost:3000 (or the port specified in your Vite configuration) to view the application.

Running the Test Cases

To ensure code quality and functionality, unit tests have been added using Jest and React Testing Library.

Steps to Run Tests:

  1. To run the test cases, execute the following command in the project directory:

    npm run test
  2. This command runs all the test cases and displays the results in the terminal.

Testing Framework

The application uses Jest for running unit tests, and React Testing Library for testing React components. Ensure that tests are created for all critical components to maintain robust code quality.

npm install --save-dev jest @testing-library/react @testing-library/jest-dom
  1. Make sure you have all test dependencies installed before running tests.

By following the steps outlined in this README, you can easily install, run, and test the project. Happy coding!

About

This project demonstrates advanced concepts in React, including global state management, hooks, custom hooks, lazy loading, and best practices for code reusability and app structure. It is designed to showcase efficient use of React’s core utilities, ensuring an optimized and scalable application.

Topics

Resources

Stars

Watchers

Forks

Releases

No releases published

Packages

No packages published
0