Socket
Socket
Sign inDemoInstall

@types/react-redux

Package Overview
Dependencies
9
Maintainers
1
Versions
132
Alerts
File Explorer

Advanced tools

Install Socket

Detect and block malicious and high-risk dependencies

Install

    @types/react-redux

TypeScript definitions for react-redux


Version published
Weekly downloads
4.1M
increased by3.69%
Maintainers
1
Install size
2.08 MB
Created
Weekly downloads
 

Package description

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

Readme

Source

Installation

npm install --save @types/react-redux

Summary

This package contains type definitions for react-redux (https://github.com/reduxjs/react-redux).

Details

Files were exported from https://github.com/DefinitelyTyped/DefinitelyTyped/tree/master/types/react-redux.

Additional Details

Credits

These definitions were written by Qubo, Curits Layne, Frank Tan, Nicholas Boll, Dibyo Majumdar, Valentin Descamps, Johann Rakotoharisoa, Anatoli Papirovski, Boris Sergeyev, Søren Bruus Frank, Jonathan Ziller, Dylan Vann, Yuki Ito, Kazuma Ebina, Michael Lebedev, jun-sheaf, Lenz Weber, and Mark Erikson.

FAQs

Last updated on 12 Dec 2023

Did you know?

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

Stay in touch

Get open source security insights delivered straight into your inbox.


  • Terms
  • Privacy
  • Security

Made with ⚡️ by Socket Inc