Skip to content

React Hooks Considarations

Francisco Ruiz edited this page Aug 25, 2024 · 1 revision

React hooks considerations

By default, the registered services use the singleton option enabled. This might cause conflict with native React hooks that utilize the component state, because with the singleton option enabled, the container will always return the same instance of the service. To disable, use the singleton option.

container.add('useCustomHook', () => useCustomHook(), {
  singleton: false
});

This disables the singleton option for the service's get() method. An equivalent way to disable the singleton option is to use the getFactory() method instead, which always returns a new instance of the service without the need to disable the singleton option.

1. Getting Started

2. Core Concepts

3. Middleware

4. Caching and Memoization

5. Typescript

6. Considerations

7. API Reference

8. Examples and Use Cases

9. Contributing

We welcome contributions from the community! Whether it's reporting a bug, suggesting a feature, or contributing code, your involvement is key to making Packet.js better. Please check out this section for more details.

10. Support

If you encounter any issues or bugs while using packetjs, or if you have any feature requests, please feel free to open an issue in our GitHub repository. You can report issues, track progress, and engage in discussions with the community via the following link:

11. FAQ

If you have any questions or need further assistance, feel free to reach out via the discussion board.

12. License

Clone this wiki locally