{"id":13802947,"url":"https://github.com/giannif/react-storage-context","last_synced_at":"2025-05-13T15:32:04.853Z","repository":{"id":57345801,"uuid":"131729684","full_name":"giannif/react-storage-context","owner":"giannif","description":"React - Get and set local and session storage easily using the Context API","archived":true,"fork":false,"pushed_at":"2018-06-02T17:57:06.000Z","size":414,"stargazers_count":8,"open_issues_count":0,"forks_count":1,"subscribers_count":1,"default_branch":"master","last_synced_at":"2024-11-07T05:09:48.637Z","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/giannif.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":"2018-05-01T15:29:26.000Z","updated_at":"2023-01-28T12:55:31.000Z","dependencies_parsed_at":"2022-09-13T23:20:38.461Z","dependency_job_id":null,"html_url":"https://github.com/giannif/react-storage-context","commit_stats":null,"previous_names":[],"tags_count":2,"template":false,"template_full_name":null,"repository_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/giannif%2Freact-storage-context","tags_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/giannif%2Freact-storage-context/tags","releases_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/giannif%2Freact-storage-context/releases","manifests_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/giannif%2Freact-storage-context/manifests","owner_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/owners/giannif","download_url":"https://codeload.github.com/giannif/react-storage-context/tar.gz/refs/heads/master","host":{"name":"GitHub","url":"https://github.com","kind":"github","repositories_count":225239683,"owners_count":17442808,"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-08-04T01:00:18.664Z","updated_at":"2024-11-18T19:31:11.471Z","avatar_url":"https://github.com/giannif.png","language":"JavaScript","readme":"# react-storage-context\n\n[![NPM](https://img.shields.io/npm/v/react-storage-context.svg)](https://www.npmjs.com/package/react-storage-context) [![JavaScript Style Guide](https://img.shields.io/badge/code_style-standard-brightgreen.svg)](https://standardjs.com)\n[![Coverage Status](https://coveralls.io/repos/github/giannif/react-storage-context/badge.svg?branch=master)](https://coveralls.io/github/giannif/react-storage-context?branch=master)\n\n\u003e Get and set local and session storage using the React Context API\n\n## Install\n\n```bash\nyarn add react-storage-context\n```\n\n## Usage\n\n`StorageContext`\n\nInitializes and manages storage, setting the values of the `StorageContext.Provider`\n\n```jsx\nimport StorageContext from \"react-storage-context\"\n\n@StorageContext(\"your-storage-id\")\nclass App extends PureComponent {\n  render() {\n    // children that will read and write storage\n  }\n}\n```\n\n`withStorageContext`\n\nWill provide the api as props:\n\n* `local` local storage object\n* `session` session storage object\n* `setLocal` update local storage object\n* `setSession` update session storage object\n\n```jsx\nimport { withStorageContext } from \"react-storage-context\"\n\n@withStorageContext\nclass App extends PureComponent {\n  render() {\n    // props to read\n    const {\n      local: { someLocalVal },\n      session\n    } = this.props\n    // props to invoke save methods\n    const { saveLocal, saveSession } = this.props\n    return \u003cdiv\u003e{someLocalVal}\u003c/div\u003e\n  }\n}\n```\n\n`Consumer`\n\n```jsx\nimport { Consumer } from \"react-storage-context\"\n\nclass App extends PureComponent {\n  render() {\n    // render props\n    return (\n      \u003cConsumer\u003e{({ session }) =\u003e \u003cdiv\u003eSession storage values: {JSON.stringify(session, undefined, 4)}\u003c/div\u003e}\u003c/Consumer\u003e\n    )\n  }\n}\n```\n\n## License\n\nMIT © [giannif](https://github.com/giannif)\n","funding_links":[],"categories":["Libraries"],"sub_categories":[],"project_url":"https://awesome.ecosyste.ms/api/v1/projects/github.com%2Fgiannif%2Freact-storage-context","html_url":"https://awesome.ecosyste.ms/projects/github.com%2Fgiannif%2Freact-storage-context","lists_url":"https://awesome.ecosyste.ms/api/v1/projects/github.com%2Fgiannif%2Freact-storage-context/lists"}