{"id":21404763,"url":"https://github.com/fakundo/react-hoc-with-ref","last_synced_at":"2026-01-02T23:14:21.785Z","repository":{"id":74039941,"uuid":"94202072","full_name":"fakundo/react-hoc-with-ref","owner":"fakundo","description":"Common way to get access to wrapped component through HoC","archived":false,"fork":false,"pushed_at":"2017-07-06T16:04:00.000Z","size":11,"stargazers_count":1,"open_issues_count":0,"forks_count":0,"subscribers_count":2,"default_branch":"master","last_synced_at":"2025-01-23T03:41:24.960Z","etag":null,"topics":[],"latest_commit_sha":null,"homepage":"","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/fakundo.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,"governance":null,"roadmap":null,"authors":null,"dei":null,"publiccode":null,"codemeta":null}},"created_at":"2017-06-13T10:42:17.000Z","updated_at":"2018-08-27T04:43:49.000Z","dependencies_parsed_at":"2023-03-10T05:15:24.441Z","dependency_job_id":null,"html_url":"https://github.com/fakundo/react-hoc-with-ref","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/fakundo%2Freact-hoc-with-ref","tags_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/fakundo%2Freact-hoc-with-ref/tags","releases_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/fakundo%2Freact-hoc-with-ref/releases","manifests_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/fakundo%2Freact-hoc-with-ref/manifests","owner_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/owners/fakundo","download_url":"https://codeload.github.com/fakundo/react-hoc-with-ref/tar.gz/refs/heads/master","host":{"name":"GitHub","url":"https://github.com","kind":"github","repositories_count":243902291,"owners_count":20366259,"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":[],"created_at":"2024-11-22T16:18:00.310Z","updated_at":"2026-01-02T23:14:21.754Z","avatar_url":"https://github.com/fakundo.png","language":"JavaScript","funding_links":[],"categories":[],"sub_categories":[],"readme":"## Common way to get access to wrapped component through HoC\n\n```\nnpm install react-hoc-with-ref\n```\n\nApp.js\n```javascript\nimport React, { Component, createElement } from 'react';\nimport createWithRef from 'react-hoc-with-ref';\n\nconst decorate = WrappedComponent =\u003e\n  class DecoratedApp extends createWithRef(WrappedComponent) {\n    render() {\n      return createElement(WrappedComponent, {\n        ...this.props,\n        ...this.getRefProps()\n      });\n    }\n  };\n\n@decorate\nexport default class App extends Component {\n  render() {\n    return (\u003cdiv\u003eTest\u003c/div\u003e);\n  }\n}\n```\n\nindex.js\n```javascript\nimport React, { Component } from 'react';\nimport ReactDOM from 'react-dom';\nimport App from './App';\n\nclass TestComponent extends Component {\n  appRef = (appComponent) =\u003e {\n    if (appComponent) {\n      console.log(appComponent.getWrappedInstance()); // App\n    }\n  };\n\n  render() {\n    return (\u003cApp ref={this.appRef} /\u003e);\n  }\n}\n\nReactDOM.render(\u003cTestComponent /\u003e, document.querySelector('#app'));\n```\n","project_url":"https://awesome.ecosyste.ms/api/v1/projects/github.com%2Ffakundo%2Freact-hoc-with-ref","html_url":"https://awesome.ecosyste.ms/projects/github.com%2Ffakundo%2Freact-hoc-with-ref","lists_url":"https://awesome.ecosyste.ms/api/v1/projects/github.com%2Ffakundo%2Freact-hoc-with-ref/lists"}