{"id":15295960,"url":"https://github.com/sebinsua/react-redux-simple-modal","last_synced_at":"2025-07-27T08:32:14.078Z","repository":{"id":57343345,"uuid":"73856415","full_name":"sebinsua/react-redux-simple-modal","owner":"sebinsua","description":"🔱 A simple modal switcher for React.","archived":false,"fork":false,"pushed_at":"2017-06-26T10:04:12.000Z","size":178,"stargazers_count":3,"open_issues_count":0,"forks_count":1,"subscribers_count":3,"default_branch":"master","last_synced_at":"2024-11-22T00:30:25.549Z","etag":null,"topics":["modals","react","reducer","switch"],"latest_commit_sha":null,"homepage":"","language":"JavaScript","has_issues":true,"has_wiki":null,"has_pages":null,"mirror_url":null,"source_name":null,"license":"unlicense","status":null,"scm":"git","pull_requests_enabled":true,"icon_url":"https://github.com/sebinsua.png","metadata":{"files":{"readme":"README.md","changelog":"CHANGELOG.md","contributing":null,"funding":null,"license":"LICENSE","code_of_conduct":null,"threat_model":null,"audit":null,"citation":null,"codeowners":null,"security":null,"support":null}},"created_at":"2016-11-15T21:23:22.000Z","updated_at":"2018-06-12T02:51:45.000Z","dependencies_parsed_at":"2022-09-12T07:00:27.097Z","dependency_job_id":null,"html_url":"https://github.com/sebinsua/react-redux-simple-modal","commit_stats":null,"previous_names":[],"tags_count":8,"template":false,"template_full_name":null,"repository_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/sebinsua%2Freact-redux-simple-modal","tags_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/sebinsua%2Freact-redux-simple-modal/tags","releases_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/sebinsua%2Freact-redux-simple-modal/releases","manifests_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/sebinsua%2Freact-redux-simple-modal/manifests","owner_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/owners/sebinsua","download_url":"https://codeload.github.com/sebinsua/react-redux-simple-modal/tar.gz/refs/heads/master","host":{"name":"GitHub","url":"https://github.com","kind":"github","repositories_count":227732304,"owners_count":17811362,"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":["modals","react","reducer","switch"],"created_at":"2024-09-30T18:08:45.694Z","updated_at":"2024-12-02T18:40:33.014Z","avatar_url":"https://github.com/sebinsua.png","language":"JavaScript","funding_links":[],"categories":[],"sub_categories":[],"readme":"# `react-redux-simple-modal` [![Build Status](https://travis-ci.org/sebinsua/react-redux-simple-modal.png)](https://travis-ci.org/sebinsua/react-redux-simple-modal) [![npm version](https://badge.fury.io/js/react-redux-simple-modal.svg)](https://npmjs.org/package/react-redux-simple-modal)\n\u003e A simple modal switcher for React.\n\nA super simple set of actions, a reducer and a component to display modals.\n\n## Install\n\n```sh\nnpm install --save react-redux-simple-modal\n```\n\n## Example\n\n```js\nimport React from 'react'\nimport { connect } from 'react-redux'\nimport { ModalSwitcher, openModal } from 'react-redux-simple-modal'\n\nimport ExampleModal from './ExampleModal'\nimport OtherExampleModal from './OtherExampleModal'\nimport { EXAMPLE_MODAL, OTHER_EXAMPLE_MODAL } from './constants'\n\nconst ExamplePage = ({ openModal }) =\u003e (\n  \u003cdiv className=\"example-page\"\u003e\n    \u003cModalSwitcher\n      modals={{\n        [EXAMPLE_MODAL]: ExampleModal,\n        [OTHER_EXAMPLE_MODAL]: OtherExampleModal\n      }}\n    /\u003e\n    \u003cbutton onClick={openModal.bind(null, EXAMPLE_MODAL)}\u003eOpen Example Modal\u003c/button\u003e\n    \u003cbutton onClick={openModal.bind(null, OTHER_EXAMPLE_MODAL)}\u003eOpen Other Example Modal\u003c/button\u003e\n  \u003c/div\u003e\n)\n\nexport default connect(\n  null,\n  { openModal }\n)(ExamplePage)\n```\n\n## API\n\n### Reducer\n\nYour root reducer should use the `reducer` exported by this module against its `modals` key.\n\n### Actions\n\n#### `openModal(modalType, modalParams)`\n\nThis opens the `SimpleModalComponent` referred to by `modalType`.\n\n`modalType` is a constant that references a component passed into `ModalSwitcher`'s `modals` prop.\n\n`modalParams` are a set of props that you wish to be set on the `SimpleModalComponent`.\n\n#### `closeModal()`\n\nThis removes the current modal.\n\nIt has no arguments.\n\n### Component\n\n#### `\u003cModalSwitcher modals={modals} /\u003e`\n\nThis renders a `SimpleModalComponent` iff a `modalType` that matches a key within `modals` has been set within the modals store.\n\n###### `\u003cSimpleModalComponent modalType={modalType} closeModal={closeModal} modalParams={modalParams} /\u003e`\n\n`SimpleModalComponent` describes the contract that your modals should follow.\n\nThey should use the `closeModal` prop that was passed in to close themselves.\n\nThey will receive the extra props passed in as second argument of `showModal(..., modalParams)` as a `modalParams` prop.\n","project_url":"https://awesome.ecosyste.ms/api/v1/projects/github.com%2Fsebinsua%2Freact-redux-simple-modal","html_url":"https://awesome.ecosyste.ms/projects/github.com%2Fsebinsua%2Freact-redux-simple-modal","lists_url":"https://awesome.ecosyste.ms/api/v1/projects/github.com%2Fsebinsua%2Freact-redux-simple-modal/lists"}