{"id":13796587,"url":"https://github.com/fabiospampinato/unstated-connect2","last_synced_at":"2025-05-13T00:30:54.375Z","repository":{"id":57386893,"uuid":"150215755","full_name":"fabiospampinato/unstated-connect2","owner":"fabiospampinato","description":"Connect containers to components, without sacrificing performance.","archived":true,"fork":false,"pushed_at":"2018-12-06T20:06:04.000Z","size":75,"stargazers_count":2,"open_issues_count":0,"forks_count":0,"subscribers_count":3,"default_branch":"master","last_synced_at":"2024-09-30T22:12:27.375Z","etag":null,"topics":["connect","hoc","performance","react","unstated"],"latest_commit_sha":null,"homepage":"","language":"TypeScript","has_issues":true,"has_wiki":null,"has_pages":null,"mirror_url":null,"source_name":null,"license":"mit","status":null,"scm":"git","pull_requests_enabled":true,"icon_url":"https://github.com/fabiospampinato.png","metadata":{"files":{"readme":"README.md","changelog":null,"contributing":null,"funding":null,"license":"LICENSE","code_of_conduct":null,"threat_model":null,"audit":null,"citation":null,"codeowners":null,"security":null,"support":null}},"created_at":"2018-09-25T06:08:07.000Z","updated_at":"2023-12-11T16:14:06.000Z","dependencies_parsed_at":"2022-09-13T02:53:07.215Z","dependency_job_id":null,"html_url":"https://github.com/fabiospampinato/unstated-connect2","commit_stats":null,"previous_names":["fabiospampinato/unstated-connect"],"tags_count":0,"template":false,"template_full_name":null,"repository_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/fabiospampinato%2Funstated-connect2","tags_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/fabiospampinato%2Funstated-connect2/tags","releases_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/fabiospampinato%2Funstated-connect2/releases","manifests_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/fabiospampinato%2Funstated-connect2/manifests","owner_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/owners/fabiospampinato","download_url":"https://codeload.github.com/fabiospampinato/unstated-connect2/tar.gz/refs/heads/master","host":{"name":"GitHub","url":"https://github.com","kind":"github","repositories_count":225159871,"owners_count":17430200,"icon_url":"https://github.com/github.png","version":null,"created_at":"2022-05-30T11:31:42.601Z","updated_at":"2022-07-04T15:15:14.044Z","host_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub","repositories_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories","repository_names_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repository_names","owners_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/owners"}},"keywords":["connect","hoc","performance","react","unstated"],"created_at":"2024-08-03T23:01:12.209Z","updated_at":"2024-11-18T10:31:26.435Z","avatar_url":"https://github.com/fabiospampinato.png","language":"TypeScript","funding_links":[],"categories":["Packages"],"sub_categories":[],"readme":"# Unstated Connect2\n\nConnect containers to components, without sacrificing performance.\n\nThis library basically combines together [react-selectr](https://github.com/fabiospampinato/react-selectr), [react-should-component-update](https://github.com/fabiospampinato/react-should-component-update) and [unstated-with-containers](https://github.com/fabiospampinato/unstated-with-containers) together.\n\n## Install\n\n```sh\nnpm install --save unstated-connect2\n```\n\n## API\n\n```ts\nconnect ({\n  container?: UnstatedContainer, // Single unstated container to connect\n  containers?: UnstatedContainer[], // Array of unstated containers to connect\n  shouldComponentUpdate?: rule | rule[], // Rule/rules to pass to `react-should-component-update`\n  selector?: Function, // Selector function to pass to `react-selectr`\n  pure?: false // Option to pass to `react-selectr`\n})\n```\n\n## Usage\n\n```ts\nimport connect from 'unstated-connect2';\nimport MyContainer from './my_container';\nimport MyOtherContainer from './my_other_container';\nimport MyComponent from './my_component';\n\n// The following code will:\n// 1. Pass the value of `container` to `unstated-with-containers`, ensuring it gets connected\n// 2. Pass the value of `shouldComponentUpdate` to `react-should-component-update`, ensuring unnecessary selections and re-renders are reduced\n// 3. Pass the value of `selector` to `react-selectr`, ensuring MyComponent will only receive the selected props, minimizing unecessary re-renders\n\nconnect ({\n  container: MyContainer,\n  shouldComponentUpdate: 'path.to.relevant.prop',\n  selector: ({ container }) =\u003e {\n    foo: container.foo,\n    bar: container.getBar ()\n  }\n})( MyComponent )\n\n// If all you need is subscribing to one or multiple containers, you can simply write:\n\nconnect ( MyContainer )( MyComponent );\nconnect ( [MyContainer, MyOtherContainer] )( MyComponent );\n```\n\n## Related\n\n- **[unstated-with-containers](https://github.com/fabiospampinato/unstated-with-containers)**: Higher-Order Component for subscribing to containers.\n- **[unstated-hmr](https://github.com/fabiospampinato/unstated-hmr)**: Preserve containers' states across Hot-Module-Replacements.\n- **[unstated-compose](https://github.com/fabiospampinato/unstated-compose)**: Compose multiple containers into one.\n- **[unstated-compose-suspense](https://github.com/fabiospampinato/unstated-compose-suspense)**: Add suspend/unsuspend support to `unstated-compose`.\n- **[unstated-compose-suspense-middleware](https://github.com/fabiospampinato/unstated-compose-suspense-middleware)**: Add middlewares support to `unstated-compose-suspense`.\n- **[unstated-suspense](https://github.com/fabiospampinato/unstated-suspense)**: Suspend/unsuspend updates propagation from your containers.\n- **[unstated-suspense-middleware](https://github.com/fabiospampinato/unstated-suspense-middleware)**: Add middlewares support to `unstated-suspense`.\n\n## License\n\nMIT © Fabio Spampinato\n","project_url":"https://awesome.ecosyste.ms/api/v1/projects/github.com%2Ffabiospampinato%2Funstated-connect2","html_url":"https://awesome.ecosyste.ms/projects/github.com%2Ffabiospampinato%2Funstated-connect2","lists_url":"https://awesome.ecosyste.ms/api/v1/projects/github.com%2Ffabiospampinato%2Funstated-connect2/lists"}