{"id":13422537,"url":"https://github.com/reactive-elements/reactive-elements","last_synced_at":"2025-12-12T04:13:41.686Z","repository":{"id":15340761,"uuid":"18071368","full_name":"reactive-elements/reactive-elements","owner":"reactive-elements","description":"Allows to use React.js component as HTML element (web component)","archived":false,"fork":false,"pushed_at":"2022-12-09T16:51:36.000Z","size":2986,"stargazers_count":696,"open_issues_count":34,"forks_count":45,"subscribers_count":18,"default_branch":"master","last_synced_at":"2025-05-14T00:01:16.082Z","etag":null,"topics":["reactjs","webcomponents"],"latest_commit_sha":null,"homepage":"","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/reactive-elements.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":"2014-03-24T17:24:07.000Z","updated_at":"2025-03-04T10:57:28.000Z","dependencies_parsed_at":"2022-09-04T03:51:43.205Z","dependency_job_id":null,"html_url":"https://github.com/reactive-elements/reactive-elements","commit_stats":null,"previous_names":["pixelscommander/reactiveelements"],"tags_count":21,"template":false,"template_full_name":null,"repository_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/reactive-elements%2Freactive-elements","tags_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/reactive-elements%2Freactive-elements/tags","releases_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/reactive-elements%2Freactive-elements/releases","manifests_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/reactive-elements%2Freactive-elements/manifests","owner_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/owners/reactive-elements","download_url":"https://codeload.github.com/reactive-elements/reactive-elements/tar.gz/refs/heads/master","host":{"name":"GitHub","url":"https://github.com","kind":"github","repositories_count":254459084,"owners_count":22074604,"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":["reactjs","webcomponents"],"created_at":"2024-07-30T23:00:47.382Z","updated_at":"2025-12-12T04:13:41.651Z","avatar_url":"https://github.com/reactive-elements.png","language":"JavaScript","readme":"\u003ca href=\"http://pixelscommander.com/polygon/reactive-elements/example/#.U0LMA62Sy7o\"\u003e\n    \u003cimg alt=\"Reactive Elements\" src=\"http://pixelscommander.com/polygon/reactive-elements/assets/logo-reactive-elements-small.png\"/\u003e\n\u003c/a\u003e\n\n# Note! The docs here are for the v1.0.0 alpha. This is _not_ ready for production use yet.\n\nYou should use this README, which refers to 0.10.0, the latest stable version on npm: https://github.com/PixelsCommander/ReactiveElements/blob/7cce3d7b472989878ac1433cec0e8168fd4136aa/README.md\n\n\n\n# Convert React.js components into Web Components\n\n```sh\nnpm install reactive-elements\nyarn add reactive-elements\n```\n\n## How to use?\n\n### Directly in a browser\n\n**Placing component in a pure HTML**\n\n```html\n\u003cbody\u003e\n\t\u003cmy-react-component items=\"{window.someArray}\"\u003e\u003c/my-react-component\u003e\n\u003c/body\u003e\n```\n\n**React class definition**\n\n```js\n/* @jsx React.DOM */\nMyComponent = React.createClass({\n  render: function() {\n    console.log(this.props.items); // passed as HTML tag`s argument\n    console.log(this.props.children); // original tag children\n    return (\n      \u003cul\u003e\n        \u003cli\u003eReact content\u003c/li\u003e\n      \u003c/ul\u003e\n    );\n  },\n});\n\nReactiveElements('my-react-component', MyComponent);\n```\n\n### With Bundler\n\n```js\nimport React, { Component } from 'react';\nimport ReactiveElements from 'reactive-elements';\n\nclass Welcome extends Component {\n  render() {\n    return \u003ch1\u003eHello, {this.props.name}\u003c/h1\u003e;\n  }\n}\n\nReactiveElements('welcome-component', Welcome);\n```\n\n## Nesting\n\nOriginal children of a custom element is injected to component as\n`this.props.children`.\n\n```html\n\u003cmy-react-component\u003eHello world\u003c/my-react-component\u003e\n```\n\nIn this case `this.props.children` is equal to \"Hello world\".\n\nContainer node of the element is passed as `this.props.container`. Both\nprops.container and props.children have type of `documentFragment`.\n\n## Boolean attribute transforms (added in version 0.7.0)\n\nAn attribute that has the value `\"true\"` or `\"false\"` will be converted into the\nboolean `true` or `false` when given to the React component:\n\n```html\n\u003cmy-react-component is-logged-in=\"true\"\u003eHello world\u003c/my-react-component\u003e\n```\n\nHere, `this.props.isLoggedIn === true` within the React component.\n\nIf you don't want this behaviour you can disable it with a special attribute:\n\n```html\n\u003cmy-react-component is-logged-in=\"true\" reactive-elements-no-boolean-transform\u003eHello world\u003c/my-react-component\u003e\n```\n\n## Exposing components methods on custom element\n\nIf you want to expose React component methods on custom element - assign them to\ncomponent as following:\n\n```js\ncomponentDidMount: function() {\n    this.props.container.setTextContent = this.setTextContent.bind(this);\n}\n```\n\n## Handling attributes change\n\nYou may add `attributeChanged` callback to component in order to handle / modify\n/ filter incoming values.\n\n```js\nattributeChanged: function(attributeName, oldValue, newValue) {\n    console.log('Attribute ' + attributeName + ' was changed from ' + oldValue + ' to ' + newValue);\n    this.props[attributeName] = parseInt(newValue);\n}\n```\n\n## Communicate via DOM events\n\nYou may trigger DOM event from React component by using following snippet:\n\n```js\nvar event = new CustomEvent('change', {\n  bubbles: true,\n});\nReact.findDOMNode(this).dispatchEvent(event);\n```\n\nSubscribing to DOM events is similar:\n\n```js\nReact.findDOMNode(this).addEventListener('change', function(e){...});\n```\n\n## Options\n\nYou can also specify options to the `ReactiveElements` call, e.g.\n\n```js\nReactiveElements('welcome-component', Welcome, options);\n```\n\n### `options.useShadowDom` _(default `false`)_\n\nBy default, your React element is rendered directly into the web-component root. However, by setting this option - your React element will instead be rendered in a [Shadow DOM](https://developer.mozilla.org/en-US/docs/Web/Web_Components/Using_shadow_DOM) inside the web-component instead.\n\n## Dependencies\n\n- [React.js](https://github.com/facebook/react)\n- [React DOM](https://github.com/facebook/react)\n- Custom elements support or\n  [polyfill](https://github.com/WebComponents/webcomponentsjs)\n- Support or [polyfills](https://github.com/zloirock/core-js) for:\n  - `regexp.match`\n  - `regexp.replace`\n  - `object.define-setter`\n  - `object.define-getter`\n  - `object.define-property`\n  - `function.name`\n  - `web.dom.iterable`\n  - `array.iterator`\n  - `object.keys`\n  - `object.set-prototype-of`\n  - `reflect.construct`\n  - `function.bind`\n\n## License\n\nMIT: http://mit-license.org/\n\nCopyright 2014 Denis Radin aka [PixelsCommander](http://pixelscommander.com)\n\nInspired by Christopher Chedeau`s\n[react-xtags](http://github.com/vjeux/react-xtags/)\n","funding_links":[],"categories":["Utilities"],"sub_categories":["Framework bindings / integrations"],"project_url":"https://awesome.ecosyste.ms/api/v1/projects/github.com%2Freactive-elements%2Freactive-elements","html_url":"https://awesome.ecosyste.ms/projects/github.com%2Freactive-elements%2Freactive-elements","lists_url":"https://awesome.ecosyste.ms/api/v1/projects/github.com%2Freactive-elements%2Freactive-elements/lists"}