New Research: Supply Chain Attack on Axios Pulls Malicious Dependency from npm.Details →
Socket
Book a DemoSign in
Socket

fioc-react

Package Overview
Dependencies
Maintainers
1
Versions
14
Alerts
File Explorer

Advanced tools

Socket logo

Install Socket

Detect and block malicious and high-risk dependencies

Install

fioc-react

A lightweight and type-safe dependency injection library for React, designed to simplify dependency management with hooks and context providers.

latest
Source
npmnpm
Version
1.3.10
Version published
Weekly downloads
1
Maintainers
1
Weekly downloads
 
Created
Source

FIOC-React

FIOC-React (Functional Inversion Of Control - React) is a lightweight dependency injection library for React applications. It simplifies the management of dependencies in your React components by providing a flexible and type-safe way to define, register, and resolve dependencies, without the need of reflection, decorators or classes.

Based on FIOC.

Features

  • Type-Safe Dependency Injection: Define and resolve dependencies with full TypeScript support.
  • Non String Tokens: Define and resolve dependencies with non-string tokens.
  • React Integration: Built specifically for React, with hooks and context providers.
  • Lightweight: Minimal overhead, designed to integrate seamlessly into your existing React projects.
  • As Complex as You Want: Going from just registering implementations of interfaces to registering consumers/use cases with recursive dependencies resolution.

Installation

Install the library using npm, pnpm or yarn:

npm install fioc-react
pnpm install fioc-react
yarn add fioc-react

1. Configuring Dependencies Provider

For details of how to configure the Container Manager see FIOC. Use the DependenciesProvider to provide the container manager to your application:

import { DependenciesProvider } from "fioc-react";
import { DIManager } from "./containers";

const App = () => {
  return (
    <DependenciesProvider manager={DIManager}>
      <p>API URL: {config.apiUrl}</p>
    </DependenciesProvider>
  );
};

2. Resolve Dependencies

Use the useDependencies hook to resolve dependencies in your components:

import { useDependencies } from "fioc-react";
import { ApiServiceToken } from "./interfaces/ApiService";

const MyComponent = () => {
  const apiService = useDependencies().resolve(ApiServiceToken);

  return (
    <div>
      <p>API URL: {apiService.getData()}</p>
    </div>
  );
};

License

This library is licensed under the MIT License. See the LICENSE file for details.

Contributing

Contributions are welcome! Feel free to open issues or submit pull requests on GitHub.

Acknowledgments

Special thanks to the open-source community for inspiring this project.

Keywords

react

FAQs

Package last updated on 02 Oct 2025

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