{"id":25541349,"url":"https://github.com/alfredosalzillo/react-pendulum","last_synced_at":"2025-04-11T17:02:12.353Z","repository":{"id":57342375,"uuid":"312876582","full_name":"alfredosalzillo/react-pendulum","owner":"alfredosalzillo","description":"A React Context utility library.","archived":false,"fork":false,"pushed_at":"2021-08-13T12:24:14.000Z","size":1092,"stargazers_count":21,"open_issues_count":0,"forks_count":1,"subscribers_count":1,"default_branch":"main","last_synced_at":"2025-03-18T13:19:14.174Z","etag":null,"topics":["multiprovider","react","treeshakable","utility","utility-library"],"latest_commit_sha":null,"homepage":"","language":"TypeScript","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/alfredosalzillo.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":"2020-11-14T18:24:41.000Z","updated_at":"2024-10-21T15:48:45.000Z","dependencies_parsed_at":"2022-09-16T03:01:50.879Z","dependency_job_id":null,"html_url":"https://github.com/alfredosalzillo/react-pendulum","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/alfredosalzillo%2Freact-pendulum","tags_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/alfredosalzillo%2Freact-pendulum/tags","releases_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/alfredosalzillo%2Freact-pendulum/releases","manifests_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/alfredosalzillo%2Freact-pendulum/manifests","owner_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/owners/alfredosalzillo","download_url":"https://codeload.github.com/alfredosalzillo/react-pendulum/tar.gz/refs/heads/main","host":{"name":"GitHub","url":"https://github.com","kind":"github","repositories_count":248446659,"owners_count":21105130,"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":["multiprovider","react","treeshakable","utility","utility-library"],"created_at":"2025-02-20T06:35:11.488Z","updated_at":"2025-04-11T17:02:12.319Z","avatar_url":"https://github.com/alfredosalzillo.png","language":"TypeScript","funding_links":[],"categories":[],"sub_categories":[],"readme":"# react-pendulum\n\nA [React Context](https://it.reactjs.org/docs/context.html) utility library.\n\n[![NPM](https://img.shields.io/npm/v/react-pendulum.svg)](https://www.npmjs.com/package/react-pendulum) [![JavaScript Style Guide](https://img.shields.io/badge/code_style-standard-brightgreen.svg)](https://standardjs.com) [![codecov](https://codecov.io/gh/alfredosalzillo/pendulum/branch/main/graph/badge.svg)](https://codecov.io/gh/alfredosalzillo/pendulum)\n\n## Install\n\nUsing npm\n```bash\nnpm install --save react-pendulum\n```\nUsing yarn\n```bash\nyarn add react-pendulum\n```\n\n## Components\n\n- [MultiProvider](#multiprovider)\n\n### MultiProvider\n\nA component to clean up the nasty code you get from taking advantage of [React Context](https://it.reactjs.org/docs/context.html) API.\n\nProps\n- `providers` the array of providers instances to wrap to the `children`\n\n```tsx\nimport React, { Component, createContext } from 'react'\nimport { MultiProvider } from 'react-pendulum'\n\nconst FirstNameContext = createContext\u003cstring\u003e('John')\nconst LastNameContext = createContext\u003cstring\u003e('Doe')\n\nconst HelloWorld = () =\u003e {\n  const firstName = useContext(FirstNameContext)\n  const lastName = useContext(LastNameContext)\n  return \u003c\u003e{`Hello ${firstName} ${lastName}`}\u003c/\u003e\n}\n\nclass App extends Component {\n  render() {\n    return (\n      \u003cMultiProvider\n        providers={[\n          \u003cFirstNameContext.Provider value='Yugi' /\u003e,\n          \u003cLastNameContext.Provider value='Muto' /\u003e\n        ]}\n      \u003e\n      \u003cHelloWorld /\u003e\n    \u003c/MultiProvider\u003e\n    )\n  }\n}\n```\n\n## Utilities\n\n- [withContext](#withcontext)\n\n### withContext\nA high order function to create the `withContext` HOC for any `Context`.\n\nArgs:\n- `Context` the context to assign the value\n- `propsName` the props name to assign the value of `Context`\n\n```tsx\nimport React, { Component, createContext } from 'react'\nimport { withContext } from 'react-pendulum'\n\nconst NameContext = createContext\u003cstring\u003e('John Doe')\n\nconst withName = withContext(NameContext, 'name');\nconst HelloWorld = withName(({ name }) =\u003e {\n  return \u003c\u003e{`Hello ${name}`}\u003c/\u003e\n})\n```\n\n## License\n\nMIT © [](https://github.com/)\n","project_url":"https://awesome.ecosyste.ms/api/v1/projects/github.com%2Falfredosalzillo%2Freact-pendulum","html_url":"https://awesome.ecosyste.ms/projects/github.com%2Falfredosalzillo%2Freact-pendulum","lists_url":"https://awesome.ecosyste.ms/api/v1/projects/github.com%2Falfredosalzillo%2Freact-pendulum/lists"}