effector-react-inject
TypeScript icon, indicating that this package has built-in type declarations

0.1.5 • Public • Published

Effector-react-inject

Inject Effector's state to React components simple way

Usage

Connecting to React components

export const Todos = inject({ todos, user })(TodoList);

TodoList component then will receive todos and user props with state from todos and user effector stores respectively.

Connecting to React class components using decorators

@inject({ todos, user })
export class TodoList extends React.Component {

Babel decorators

TypeScript decorators

TypeScript declarations

import { inject, Injected } from 'effector-react-inject';

const stores = { todos, user };

type TodoListProps = OwnProps & Injected<typeof stores>;

class TodoList extends React.Component<TodoListProps> {

Motivation

  • Classic redux-connect-like HOC syntax, can be easily composed.

  • Less dependent on Effector's core API, especially if injecting multiple stores.

  • Can be used as a decorator for React class components

  • Wrappable components can be tested separately

Package Sidebar

Install

npm i effector-react-inject

Weekly Downloads

1

Version

0.1.5

License

ISC

Unpacked Size

4.65 kB

Total Files

5

Last publish

Collaborators

  • today-