{"id":18879365,"url":"https://github.com/austinsc/react-ref-decorator","last_synced_at":"2026-02-20T00:30:16.255Z","repository":{"id":57343400,"uuid":"49963193","full_name":"austinsc/react-ref-decorator","owner":"austinsc","description":"An ES7 decorator for reffing and unreffing objects (anything that implements .ref() and .unref()) in the componentWillMount() and componentWillUnmount()","archived":false,"fork":false,"pushed_at":"2016-01-21T17:47:06.000Z","size":30,"stargazers_count":0,"open_issues_count":0,"forks_count":1,"subscribers_count":1,"default_branch":"master","last_synced_at":"2025-02-08T16:45:22.663Z","etag":null,"topics":[],"latest_commit_sha":null,"homepage":null,"language":"JavaScript","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/austinsc.png","metadata":{"files":{"readme":"README.md","changelog":"CHANGELOG.md","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":"2016-01-19T15:46:26.000Z","updated_at":"2018-03-01T20:10:17.000Z","dependencies_parsed_at":"2022-09-12T07:00:26.775Z","dependency_job_id":null,"html_url":"https://github.com/austinsc/react-ref-decorator","commit_stats":null,"previous_names":["rovisys/react-ref-decorator"],"tags_count":5,"template":false,"template_full_name":null,"repository_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/austinsc%2Freact-ref-decorator","tags_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/austinsc%2Freact-ref-decorator/tags","releases_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/austinsc%2Freact-ref-decorator/releases","manifests_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/austinsc%2Freact-ref-decorator/manifests","owner_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/owners/austinsc","download_url":"https://codeload.github.com/austinsc/react-ref-decorator/tar.gz/refs/heads/master","host":{"name":"GitHub","url":"https://github.com","kind":"github","repositories_count":239841743,"owners_count":19705981,"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-08T06:35:34.802Z","updated_at":"2026-02-20T00:30:16.212Z","avatar_url":"https://github.com/austinsc.png","language":"JavaScript","readme":"[![Build Status](http://img.shields.io/travis/RoviSys/react-ref-decorator.svg?style=flat)](https://travis-ci.org/RoviSys/react-ref-decorator)\n[![Code Climate](https://codeclimate.com/github/RoviSys/react-ref-decorator/badges/gpa.svg)](https://codeclimate.com/github/RoviSys/react-ref-decorator)\n[![Test Coverage](https://codeclimate.com/github/RoviSys/react-ref-decorator/badges/coverage.svg)](https://codeclimate.com/github/RoviSys/react-ref-decorator/coverage)\n[![Dependency Status](https://david-dm.org/RoviSys/react-ref-decorator.svg)](https://david-dm.org/RoviSys/react-ref-decorator)\n[![devDependency Status](https://david-dm.org/RoviSys/react-ref-decorator/dev-status.svg)](https://david-dm.org/RoviSys/react-ref-decorator#info=devDependencies)\n\n# react-ref-decorator\n\n \u003e An ES7 decorator for reffing and unreffing objects (anything that implements .ref() and .unref()) in the componentWillMount() and componentWillUnmount()\n\n## Installation\n\nJust run `npm install --save react-ref-decorator` and then use the default export of the module.\n\n## Purpose\n\nThe purpose of this module is to add some abbreviated syntax for hooking into a component's mount lifecycle. \n\n## Example\n\nLets say you have some object that needs to be tied to the mounted portion of a React component's lifecycle:\n\n```javascript\nconst componentWatcher = {\n  ref() {\n    // do something when the component mounts\n  }\n  \n  unref() {\n    // do something else when the component unmounts\n  }\n};\n```\n\nYou can attach it like this:\n\n```javascript\nimport Ref from 'react-ref-decorator';\n\n@Ref(componentWatcher)\nclass MyComponent extends Component {\n  render() {\n    return (\n      \u003ch1\u003eBlah\u003c/h1\u003e\n    );\n  }\n}\n```\n\nThe decorator also supports multiple 'reffable' arguments:\n \n```javascript\nimport Ref from 'react-ref-decorator';\n\n@Ref(componentWatcher1, componentWatcher2, componentWatcher3)\nclass MyComponent extends Component {\n  render() {\n    return (\n      \u003ch1\u003eBlah\u003c/h1\u003e\n    );\n  }\n}\n```\n\nNow when the component mounts and unmounts your componentWatchers ref/unref functions will be called respectively.","funding_links":[],"categories":[],"sub_categories":[],"project_url":"https://awesome.ecosyste.ms/api/v1/projects/github.com%2Faustinsc%2Freact-ref-decorator","html_url":"https://awesome.ecosyste.ms/projects/github.com%2Faustinsc%2Freact-ref-decorator","lists_url":"https://awesome.ecosyste.ms/api/v1/projects/github.com%2Faustinsc%2Freact-ref-decorator/lists"}