{"id":19529893,"url":"https://github.com/loopmode/react-provide-forage","last_synced_at":"2025-06-30T10:32:11.947Z","repository":{"id":57342870,"uuid":"127467029","full_name":"loopmode/react-provide-forage","owner":"loopmode","description":"HOC and decorator for feeding localforage values to react components","archived":false,"fork":false,"pushed_at":"2018-12-05T09:03:59.000Z","size":31,"stargazers_count":1,"open_issues_count":0,"forks_count":0,"subscribers_count":1,"default_branch":"master","last_synced_at":"2025-05-28T14:18:03.033Z","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":null,"status":null,"scm":"git","pull_requests_enabled":true,"icon_url":"https://github.com/loopmode.png","metadata":{"files":{"readme":"README.md","changelog":"CHANGELOG.md","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":"2018-03-30T19:47:28.000Z","updated_at":"2018-12-05T09:04:00.000Z","dependencies_parsed_at":"2022-09-16T03:02:06.457Z","dependency_job_id":null,"html_url":"https://github.com/loopmode/react-provide-forage","commit_stats":null,"previous_names":[],"tags_count":1,"template":false,"template_full_name":null,"purl":"pkg:github/loopmode/react-provide-forage","repository_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/loopmode%2Freact-provide-forage","tags_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/loopmode%2Freact-provide-forage/tags","releases_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/loopmode%2Freact-provide-forage/releases","manifests_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/loopmode%2Freact-provide-forage/manifests","owner_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/owners/loopmode","download_url":"https://codeload.github.com/loopmode/react-provide-forage/tar.gz/refs/heads/master","sbom_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/loopmode%2Freact-provide-forage/sbom","host":{"name":"GitHub","url":"https://github.com","kind":"github","repositories_count":262450328,"owners_count":23313015,"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-11T01:28:03.344Z","updated_at":"2025-06-30T10:32:11.885Z","avatar_url":"https://github.com/loopmode.png","language":"JavaScript","funding_links":[],"categories":[],"sub_categories":[],"readme":"# react-provide-forage\n\nA higher-order-componennt and a decorator for providing localforage values to react components.\n\n## Usage\n\n### Component\n\nIf you want to provide localforage data to child components in the JSX tree you control, you can use the component:\n\n```javascript\nimport React, { Component } from 'react';\nimport ProvideForage from 'react-provide-forage'\nimport localforage from 'localforage';\n\nexport default class MyComponent extends Component {\n    render() {\n        return ( \n            \u003cProvideForage storage={localforage} provide=\"activeIndex\"\u003e\n                \u003cMyTabbedComponent\n                    items={this.props.items}\n                    foo=\"bar\"\n                    bar=\"baz\"\n                /\u003e\n            \u003c/ProvideForage\u003e \n        );\n    }\n}\n\n```\n\nThe `MyTabbedComponent` will receive an additional prop `activeIndex` as soon as the value is loaded from localforage.\n\n\n### Decorator\n\nIf you want to provide data \"to yourself\", you can use the decorator:\n\n\n```javascript\nimport React, { Component } from 'react';\nimport { connectForage } from 'react-provide-forage'; \nimport localforage from 'localforage';\n\n@connectForage(localforage, ['activeIndex'])\nexport default class MyComponent extends Component {\n    static propTypes = {\n        activeIndex: PropTypes.number\n    };\n    render() {\n        return ( \n            \u003cMyTabbedComponent\n                activeIndex={this.props.activeIndex}\n                items={this.props.items}\n                foo=\"bar\"\n                bar=\"baz\"\n            /\u003e \n        );\n    }\n}\n\n\n```\n\nIf you prefer not to use ES7 decorator syntax, you can write the same as:\n\n\n```javascript\nimport React, { Component } from 'react';\nimport { connectForage } from 'react-provide-forage'; \nimport localforage from 'localforage';\n\nconst withForage = connectForage(localforage, ['activeIndex']);\n\nclass MyComponent extends Component {\n    static propTypes = {\n        activeIndex: PropTypes.number\n    };\n    render() {\n        return ( \n            \u003cMyTabbedComponent\n                activeIndex={this.props.activeIndex}\n                items={this.props.items}\n                foo=\"bar\"\n                bar=\"baz\"\n            /\u003e \n        );\n    }\n}\n\nexport default withForage(MyComponent)\n\n```\n\n\n","project_url":"https://awesome.ecosyste.ms/api/v1/projects/github.com%2Floopmode%2Freact-provide-forage","html_url":"https://awesome.ecosyste.ms/projects/github.com%2Floopmode%2Freact-provide-forage","lists_url":"https://awesome.ecosyste.ms/api/v1/projects/github.com%2Floopmode%2Freact-provide-forage/lists"}