{"id":29027311,"url":"https://github.com/cahnory/create-react-factory","last_synced_at":"2026-04-24T22:32:50.329Z","repository":{"id":57148013,"uuid":"81459918","full_name":"cahnory/create-react-factory","owner":"cahnory","description":"React component factory factory","archived":false,"fork":false,"pushed_at":"2017-02-15T08:57:12.000Z","size":4,"stargazers_count":1,"open_issues_count":0,"forks_count":0,"subscribers_count":1,"default_branch":"master","last_synced_at":"2025-06-04T21:23:16.460Z","etag":null,"topics":["factory","higher-order-component","react","reactjs"],"latest_commit_sha":null,"homepage":null,"language":"JavaScript","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/cahnory.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":"2017-02-09T14:43:01.000Z","updated_at":"2017-11-24T19:52:42.000Z","dependencies_parsed_at":"2022-09-06T18:10:14.477Z","dependency_job_id":null,"html_url":"https://github.com/cahnory/create-react-factory","commit_stats":null,"previous_names":[],"tags_count":0,"template":false,"template_full_name":null,"purl":"pkg:github/cahnory/create-react-factory","repository_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/cahnory%2Fcreate-react-factory","tags_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/cahnory%2Fcreate-react-factory/tags","releases_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/cahnory%2Fcreate-react-factory/releases","manifests_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/cahnory%2Fcreate-react-factory/manifests","owner_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/owners/cahnory","download_url":"https://codeload.github.com/cahnory/create-react-factory/tar.gz/refs/heads/master","sbom_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/cahnory%2Fcreate-react-factory/sbom","host":{"name":"GitHub","url":"https://github.com","kind":"github","repositories_count":262010868,"owners_count":23244414,"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":["factory","higher-order-component","react","reactjs"],"created_at":"2025-06-26T06:05:23.708Z","updated_at":"2026-04-24T22:32:45.295Z","avatar_url":"https://github.com/cahnory.png","language":"JavaScript","funding_links":[],"categories":[],"sub_categories":[],"readme":"# create-react-factory\n\n**create-react-factory** create a factory for your react component. It allows you to:\n+ compose multiple high order components\n+ set a custom component to render using the *component* property\n\n## Installation\n\n```\nnpm install create-react-factory\n```\n\n## Usage\n\n```javascript\n// Underline.js\nimport React from 'react'\nimport createReactFactory from 'create-react-factory'\n\nexport const Underline = ({component: Component = 'div', style = {}, ...props}) =\u003e (\n  \u003cComponent style={{...style, textDecoration: 'underline'}} {...props} /\u003e\n)\nexport default Underline\nexport const factory = createReactFactory(Underline)\n```\n\n```javascript\n// Strong.js\nimport React from 'react'\nimport createReactFactory from 'create-react-factory'\n\nexport const Strong = ({component: Component = 'div', style = {}, ...props}) =\u003e (\n  \u003cComponent style={{...style, fontWeight: 'bold'}} {...props} /\u003e\n)\nexport default Strong\nexport const factory = createReactFactory(Strong)\n```\n\n```javascript\n// Red.js\nimport React from 'react'\nimport createReactFactory from 'create-react-factory'\n\nconst Red = ({component: Component = 'div', style = {}, ...props}) =\u003e (\n  \u003cComponent style={{...style, color: 'red'}} {...props} /\u003e\n)\nexport default Red\nexport const factory = createReactFactory(Red)\n```\n\n```javascript\n// RedStrongUnderline.js\nimport {factory as strongFactory} from './Strong'\nimport {factory as redFactory} from './Red'\nimport Underline from './Underline'\n\nexport const RedStrongUnderline = strongFactory(redFactory(Underline))\nexport default RedStrongUnderline\n```\n\n```javascript\nimport React from 'react'\nimport {render} from 'react-dom'\nimport Rsu from './RedStrongUnderline'\n\nrender(\u003cul\u003e\u003cRsu component=\"li\"\u003eHello World!\u003c/Rsu\u003e\u003c/ul\u003e, document.getElementById('root'))\n// output:\n// \u003cul\u003e\n//   \u003cli style=\"color: red; font-weight: bold; text-decoration: underline;\"\u003e\n//     Hello World!\n//   \u003c/li\u003e\n// \u003c/ul\u003e\n```\n\n## Why?\n\nBecause with the \"traditional\" factory approach, the component property is overridden by the Component passed to the factory. Thus it become impossible to set a different component to render.\n\n## License\n\n[MIT](https://tldrlegal.com/license/mit-license)","project_url":"https://awesome.ecosyste.ms/api/v1/projects/github.com%2Fcahnory%2Fcreate-react-factory","html_url":"https://awesome.ecosyste.ms/projects/github.com%2Fcahnory%2Fcreate-react-factory","lists_url":"https://awesome.ecosyste.ms/api/v1/projects/github.com%2Fcahnory%2Fcreate-react-factory/lists"}