{"id":22903953,"url":"https://github.com/json2d/react-prepare-wrapper","last_synced_at":"2026-02-05T16:32:23.276Z","repository":{"id":57342739,"uuid":"99730806","full_name":"json2d/react-prepare-wrapper","owner":"json2d","description":"a higher order component / wrapper for executing a task when a component mounts or receives props","archived":false,"fork":false,"pushed_at":"2017-08-08T21:07:25.000Z","size":3,"stargazers_count":0,"open_issues_count":0,"forks_count":0,"subscribers_count":1,"default_branch":"master","last_synced_at":"2025-10-22T03:55:26.402Z","etag":null,"topics":[],"latest_commit_sha":null,"homepage":"","language":null,"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/json2d.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":"2017-08-08T19:54:25.000Z","updated_at":"2017-08-08T21:10:59.000Z","dependencies_parsed_at":"2022-09-16T03:02:07.355Z","dependency_job_id":null,"html_url":"https://github.com/json2d/react-prepare-wrapper","commit_stats":null,"previous_names":["bitstrider/react-prepare-wrapper"],"tags_count":0,"template":false,"template_full_name":null,"purl":"pkg:github/json2d/react-prepare-wrapper","repository_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/json2d%2Freact-prepare-wrapper","tags_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/json2d%2Freact-prepare-wrapper/tags","releases_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/json2d%2Freact-prepare-wrapper/releases","manifests_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/json2d%2Freact-prepare-wrapper/manifests","owner_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/owners/json2d","download_url":"https://codeload.github.com/json2d/react-prepare-wrapper/tar.gz/refs/heads/master","sbom_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/json2d%2Freact-prepare-wrapper/sbom","scorecard":null,"host":{"name":"GitHub","url":"https://github.com","kind":"github","repositories_count":286080680,"owners_count":29125843,"icon_url":"https://github.com/github.png","version":null,"created_at":"2022-05-30T11:31:42.601Z","updated_at":"2026-02-05T14:05:12.718Z","status":"ssl_error","status_checked_at":"2026-02-05T14:03:53.078Z","response_time":65,"last_error":"SSL_read: unexpected eof while reading","robots_txt_status":"success","robots_txt_updated_at":"2025-07-24T06:49:26.215Z","robots_txt_url":"https://github.com/robots.txt","online":false,"can_crawl_api":true,"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-12-14T02:39:34.236Z","updated_at":"2026-02-05T16:32:23.259Z","avatar_url":"https://github.com/json2d.png","language":null,"funding_links":[],"categories":[],"sub_categories":[],"readme":"# react-prepare-wrapper\n\na higher order component / wrapper for executing a task when a component mounts or receives props\n\n## Installation\n\n```sh\nnpm install react-prepare-wrapper --save-dev\n```\n\n## Usage\n\nHere's a way to use this with the `connect` wrapper from `react-redux` to create a kind of **'smart container'** that can auto-fetch missing state data:\n\n```javascript\nimport React, {Component} from 'react';\nimport {connect} from 'react-redux';\nimport prepare from 'react-prepare-wrapper'\n\nimport {fetchThings} from 'actions/app'\nimport {selectThings} from 'selectors/app'\nimport {ThingsCard, LoadingSpinner} from 'components/app'\n\nconst mstp = state =\u003e ({\n    things: selectThings(state)\n})\n\nconst onProps = props =\u003e {\n    const {things, dispatch} = props\n    if(!things) {\n        dispatch(fetchThings())\n    }\n}\n\n@connect(mstp)\n@prepare(onProps)\nexport default class ThingsContainer extends Component {\n\n    render() {\n        const {things} = this.props\n        return (\n            \u003cdiv className=\"things\"\u003e\n                {things ?\n                    \u003cThingsCard things={things} /\u003e\n                    : \u003cLoadingSpinner /\u003e\n                }\n            \u003c/div\u003e\n        );\n    }\n}\n\n```\n\nWhen a `ThingsContainer` is mounted with an empty global state, it dispatches an action to fetch `things` and meanwhile renders `\u003cLoadingSpinner/\u003e`. After `things` is successfully fetched and merged into the global state via a reducer, the component will be rerendered with `\u003cThingsCard/\u003e`.\n\n## Dev Dependencies\n\n- [babel-cli](https://github.com/babel/babel/tree/master/packages): Babel command line.\n- [babel-core](https://github.com/babel/babel/tree/master/packages): Babel compiler core.\n- [babel-eslint](https://github.com/babel/babel-eslint): Custom parser for ESLint\n- [babel-preset-es2015](https://github.com/babel/babel/tree/master/packages): Babel preset for all es2015 plugins.\n- [babel-preset-react](https://github.com/babel/babel/tree/master/packages): Babel preset for all React plugins.\n- [babel-preset-stage-0](https://github.com/babel/babel/tree/master/packages): Babel preset for stage 0 plugins\n- [babel-register](https://github.com/babel/babel/tree/master/packages): babel require hook\n- [eslint](https://github.com/eslint/eslint): An AST-based pattern checker for JavaScript.\n- [eslint-config-rackt](https://github.com/rackt/eslint-config-rackt): Shareable eslint config for rackt repos\n- [eslint-plugin-react](https://github.com/yannickcr/eslint-plugin-react): React specific linting rules for ESLint\n- [react](https://github.com/facebook/react): React is a JavaScript library for building user interfaces.\n- [react-dom](https://github.com/facebook/react): React package for working with the DOM.\n- [rimraf](https://github.com/isaacs/rimraf): A deep deletion module for node (like `rm -rf`)\n\n\n## License\n\nISC\n","project_url":"https://awesome.ecosyste.ms/api/v1/projects/github.com%2Fjson2d%2Freact-prepare-wrapper","html_url":"https://awesome.ecosyste.ms/projects/github.com%2Fjson2d%2Freact-prepare-wrapper","lists_url":"https://awesome.ecosyste.ms/api/v1/projects/github.com%2Fjson2d%2Freact-prepare-wrapper/lists"}