Huge News!Announcing our $40M Series B led by Abstract Ventures.Learn More
Socket
Sign inDemoInstall
Socket

@types/react

Package Overview
Dependencies
Maintainers
1
Versions
610
Alerts
File Explorer

Advanced tools

Socket logo

Install Socket

Detect and block malicious and high-risk dependencies

Install

@types/react

TypeScript definitions for React

  • 15.0.6
  • Source
  • npm
  • Socket score

Version published
Weekly downloads
11M
decreased by-58.27%
Maintainers
1
Weekly downloads
 
Created

What is @types/react?

The @types/react package contains TypeScript type definitions for React (a JavaScript library for building user interfaces). It enables TypeScript developers to use React with type checking, which enhances development by catching errors early and providing autocompletion in code editors. This package is essential for developers working with React in TypeScript projects, as it defines the types for React APIs, components, hooks, and other utilities.

What are @types/react's main functionalities?

Component Type Definitions

Defines TypeScript types for React functional components, allowing for type checking of props.

import React from 'react';

interface Props {
  greeting: string;
}

const Greeting: React.FC<Props> = ({ greeting }) => <div>{greeting}</div>;

Hook Type Definitions

Provides type definitions for React hooks like useState, enabling type checking and autocompletion for hook-related code.

import React, { useState } from 'react';

const Counter: React.FC = () => {
  const [count, setCount] = useState<number>(0);
  return (
    <div>
      <p>{count}</p>
      <button onClick={() => setCount(count + 1)}>Increment</button>
    </div>
  );
};

Event Type Definitions

Includes type definitions for handling events in React, such as mouse and keyboard events, with appropriate type checking.

import React from 'react';

const Clicker: React.FC = () => {
  const handleClick = (event: React.MouseEvent<HTMLButtonElement>) => {
    console.log('Button clicked');
  };
  return <button onClick={handleClick}>Click Me</button>;
};

Other packages similar to @types/react

FAQs

Package last updated on 01 Feb 2017

Did you know?

Socket

Socket for GitHub automatically highlights issues in each pull request and monitors the health of all your open source dependencies. Discover the contents of your packages and block harmful activity before you install or update your dependencies.

Install

Related posts

SocketSocket SOC 2 Logo

Product

  • Package Alerts
  • Integrations
  • Docs
  • Pricing
  • FAQ
  • Roadmap
  • Changelog

Packages

npm

Stay in touch

Get open source security insights delivered straight into your inbox.


  • Terms
  • Privacy
  • Security

Made with ⚡️ by Socket Inc