{"id":16820511,"url":"https://github.com/nighttrax/react-bind-component","last_synced_at":"2025-10-30T11:22:56.689Z","repository":{"id":33955471,"uuid":"164022387","full_name":"NiGhTTraX/react-bind-component","owner":"NiGhTTraX","description":"Function.prototype.bind for React components","archived":false,"fork":false,"pushed_at":"2023-01-06T22:59:58.000Z","size":1612,"stargazers_count":2,"open_issues_count":3,"forks_count":0,"subscribers_count":2,"default_branch":"master","last_synced_at":"2025-04-03T19:41:53.320Z","etag":null,"topics":["functional-programming","react","typescript"],"latest_commit_sha":null,"homepage":"","language":"TypeScript","has_issues":true,"has_wiki":null,"has_pages":null,"mirror_url":null,"source_name":null,"license":null,"status":null,"scm":"git","pull_requests_enabled":true,"icon_url":"https://github.com/NiGhTTraX.png","metadata":{"files":{"readme":"README.md","changelog":null,"contributing":null,"funding":null,"license":null,"code_of_conduct":null,"threat_model":null,"audit":null,"citation":null,"codeowners":null,"security":null,"support":null}},"created_at":"2019-01-03T20:59:41.000Z","updated_at":"2022-11-25T10:01:49.000Z","dependencies_parsed_at":"2023-01-15T03:45:58.994Z","dependency_job_id":null,"html_url":"https://github.com/NiGhTTraX/react-bind-component","commit_stats":null,"previous_names":[],"tags_count":0,"template":false,"template_full_name":null,"repository_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/NiGhTTraX%2Freact-bind-component","tags_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/NiGhTTraX%2Freact-bind-component/tags","releases_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/NiGhTTraX%2Freact-bind-component/releases","manifests_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/NiGhTTraX%2Freact-bind-component/manifests","owner_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/owners/NiGhTTraX","download_url":"https://codeload.github.com/NiGhTTraX/react-bind-component/tar.gz/refs/heads/master","host":{"name":"GitHub","url":"https://github.com","kind":"github","repositories_count":247318746,"owners_count":20919484,"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":["functional-programming","react","typescript"],"created_at":"2024-10-13T10:57:03.717Z","updated_at":"2025-10-30T11:22:56.588Z","avatar_url":"https://github.com/NiGhTTraX.png","language":"TypeScript","readme":"\u003e Type safe `Function.prototype.bind` for React components\n\n![Build Status](https://github.com/NiGhTTraX/react-bind-component/workflows/Tests/badge.svg) [![codecov](https://codecov.io/gh/NiGhTTraX/react-bind-component/branch/master/graph/badge.svg)](https://codecov.io/gh/NiGhTTraX/react-bind-component) ![npm type definitions](https://img.shields.io/npm/types/react-bind-component.svg)\n\n----\n\n\n## Usage\n\n```tsx\nimport bindComponent from 'react-bind-component';\n\ninterface FooProps {\n  foo: number;\n  bar: number;\n}\n\nconst Foo = (props: FooProps) =\u003e null;\n\nconst BoundFoo = bindComponent(Foo, { bar: 2 });\n\nReactDOM.render(\u003cBoundFoo foo={1} /\u003e);\n```\n\nJust like `Function.prototype.bind`, `bindComponent` creates a new component\nthat renders the original one with the supplied props plus any other props\nthat are passed when the new component is rendered.\n\n\n## Examples\n\n### Partially applying components\n\nUsing the [render props](https://reactjs.org/docs/render-props.html)\ntechnique we can design components that delegate parts of their rendering\nlogic to methods passed through props. We can then bind these components to\nvarious implementations of those render props:\n\n```tsx\nimport bindComponent from 'react-bind-component';\n\ninterface ListProps {\n  items: string[];\n  renderItem: (item: string) =\u003e ReactElement;\n}\n\nconst List = (props: ListProps) =\u003e \u003cul\u003e\n  {props.items.map(item =\u003e \u003cli\u003e\n    {props.renderItem(item)}\n  \u003c/li\u003e\n\u003c/ul\u003e;\n\nconst ListWithTextLabels = bindComponent(List, {\n  renderItem: x =\u003e \u003cspan\u003e{x}\u003c/span\u003e\n});\n\nconst ListWithIcons = bindComponent(List, {\n  renderItem: x =\u003e \u003cimg src={`/imgs/${x}.png`} /\u003e\n});\n```\n","funding_links":[],"categories":[],"sub_categories":[],"project_url":"https://awesome.ecosyste.ms/api/v1/projects/github.com%2Fnighttrax%2Freact-bind-component","html_url":"https://awesome.ecosyste.ms/projects/github.com%2Fnighttrax%2Freact-bind-component","lists_url":"https://awesome.ecosyste.ms/api/v1/projects/github.com%2Fnighttrax%2Freact-bind-component/lists"}