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

@types/react-redux

Package Overview
Dependencies
Maintainers
1
Versions
133
Alerts
File Explorer

Advanced tools

Socket logo

Install Socket

Detect and block malicious and high-risk dependencies

Install

@types/react-redux

TypeScript definitions for react-redux

  • 6.0.26
  • Source
  • npm
  • Socket score

Version published
Weekly downloads
4.1M
increased by0.79%
Maintainers
1
Weekly downloads
 
Created

What is @types/react-redux?

The @types/react-redux package provides TypeScript type definitions for the react-redux library, which allows React components to interact with a Redux store. It enables type checking and IntelliSense for react-redux functions and components when using TypeScript.

What are @types/react-redux's main functionalities?

Provider Component Typing

The Provider component makes the Redux store available to any nested components that need to access the Redux store.

import { Provider } from 'react-redux';
import { store } from './store';

const App = () => (
  <Provider store={store}>
    {/* Your app components go here */}
  </Provider>
);

connect Function Typing

The connect function connects a React component to the Redux store. It provides type checking for the mapStateToProps and mapDispatchToProps arguments, as well as the component's props.

import { connect } from 'react-redux';

interface Props {
  todos: string[];
}

const TodoList: React.FC<Props> = ({ todos }) => (
  <ul>{todos.map(todo => <li key={todo}>{todo}</li>)}</ul>
);

const mapStateToProps = (state: RootState) => ({
  todos: state.todos
});

export default connect(mapStateToProps)(TodoList);

Hooks Typing

TypeScript types for the useSelector and useDispatch hooks from react-redux, which allow you to access the state and dispatch actions in a type-safe manner.

import { useSelector, useDispatch } from 'react-redux';
import { RootState } from './store';

const TodoList = () => {
  const todos = useSelector((state: RootState) => state.todos);
  const dispatch = useDispatch();

  // Use dispatch with type-checked actions
  // ...

  return <ul>{todos.map(todo => <li key={todo}>{todo}</li>)}</ul>;
};

Other packages similar to @types/react-redux

FAQs

Package last updated on 07 Nov 2023

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