{"id":15700820,"url":"https://github.com/damassi/react-responsive-decorator","last_synced_at":"2025-05-12T14:54:44.853Z","repository":{"id":150231749,"uuid":"107846539","full_name":"damassi/react-responsive-decorator","owner":"damassi","description":"A higher-order component / decorator around enquire.js","archived":false,"fork":false,"pushed_at":"2017-10-22T07:44:12.000Z","size":363,"stargazers_count":6,"open_issues_count":0,"forks_count":0,"subscribers_count":1,"default_branch":"master","last_synced_at":"2025-03-31T23:29:52.666Z","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/damassi.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,"governance":null,"roadmap":null,"authors":null,"dei":null,"publiccode":null,"codemeta":null}},"created_at":"2017-10-22T07:38:13.000Z","updated_at":"2021-02-07T22:03:18.000Z","dependencies_parsed_at":"2023-06-15T05:30:40.369Z","dependency_job_id":null,"html_url":"https://github.com/damassi/react-responsive-decorator","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/damassi%2Freact-responsive-decorator","tags_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/damassi%2Freact-responsive-decorator/tags","releases_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/damassi%2Freact-responsive-decorator/releases","manifests_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/damassi%2Freact-responsive-decorator/manifests","owner_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/owners/damassi","download_url":"https://codeload.github.com/damassi/react-responsive-decorator/tar.gz/refs/heads/master","host":{"name":"GitHub","url":"https://github.com","kind":"github","repositories_count":253759555,"owners_count":21959777,"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-10-03T19:54:35.230Z","updated_at":"2025-05-12T14:54:44.828Z","avatar_url":"https://github.com/damassi.png","language":"JavaScript","funding_links":[],"categories":[],"sub_categories":[],"readme":"# react-responsive-decorator\n\nA higher-order component / decorator wrapper around [enquire.js](http://wicky.nillia.ms/enquire.js/) that injects `media()` into component props.\n\nThis library uses [json2mq](https://github.com/akiran/json2mq) internally to convert media queries from object to string format. See [enquire.js's API](http://wicky.nillia.ms/enquire.js/#api) for more info.\n\n```javascript\nimport React from 'react';\nimport Responsive from 'react-responsive-decorator';\n\n@Responsive\nclass MyComponent extends React.Component {\n\n  state = {\n    isMobile: false\n  }\n\n  componentDidMount() {\n    this.props.media({ minWidth: 768 }, () =\u003e {\n      this.setState({\n        isMobile: false\n      });\n    });\n\n    this.props.media({ maxWidth: 768 }, () =\u003e {\n      this.setState({\n        isMobile: true\n      });\n    });\n  }\n\n  render() {\n    const { isMobile } = this.state;\n\n    return (\n      \u003cdiv\u003e\n        {isMobile ?\n          \u003cdiv\u003eMobile\u003c/div\u003e :\n          \u003cdiv\u003eNot mobile\u003c/div\u003e\n        }\n      \u003c/div\u003e\n    );\n  }\n}\n\nexport default MyComponent;\n```\n\nOr, if you'd rather return a wrapped, Higher Order component, export like so:\n\n```javascript\nimport React from 'react';\nimport Responsive from 'react-responsive-decorator';\n\nclass MyComponent extends React.Component {\n  (...)\n}\n\nexport default Responsive(MyComponent);\n```\n\n\nCredits\n=======\nThis code has been adapted from https://github.com/akiran/react-responsive-mixin in order to remove the mixin dependency.\n","project_url":"https://awesome.ecosyste.ms/api/v1/projects/github.com%2Fdamassi%2Freact-responsive-decorator","html_url":"https://awesome.ecosyste.ms/projects/github.com%2Fdamassi%2Freact-responsive-decorator","lists_url":"https://awesome.ecosyste.ms/api/v1/projects/github.com%2Fdamassi%2Freact-responsive-decorator/lists"}