Remount

使用自定义元素将 React 组件挂到 DOM 上。「Mount React components to the DOM using custom elements」

Github星跟踪图

Installation

Remount is available through the npm package repository.

  • Via yarn: yarn add remount
  • or npm: npm install remount

Usage

Let's start with any React component. Here's one:

const Greeter = ({ name }) => {
  return <div>Hello, {name}!</div>
}

Use define() to define custom elements. Let's define a <x-greeter> element:

import { define } from 'remount'

define({ 'x-greeter': Greeter })

You can now use it anywhere in your HTML! :boom:

<x-greeter props-json='{"name":"John"}'></x-greeter>

API documentation →

Use cases

Some ideas on why you might want to consider Remount for your project:, -------------------------------------------------------------, ----------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------, , ✨ Adding React to non-SPA apps You can use React components on any page of a "regular" HTML site. Great for adding React to apps built on Rails or Phoenix., , ? Interop with other frameworks Remount lets you use your React components just like any other HTML element. This means you can use React with Vue, Angular, or any other DOM library/framework., ## More features

  • JSON props (eg, <x-greeter props-json="{...}">) (docs)
  • Named attributes (eg, <x-greeter name="John">) (docs)
  • Uses Custom Elements API (when available)
  • Fallback to compatible API for other browers
  • Shadow DOM mode (when available)

Browser support

Remount supports all browsers that React support, which includes IE11. Legacy IE support (IE9) is available using polyfills.

Custom Elements API# ("Web Components") will be used if it's available (Chrome/67+), and will fallback to a compatible API otherwise.

Browser support docs →

Documentation

Thanks

remount © 2018, Rico Sta. Cruz. Released under the MIT License.
Authored and maintained by Rico Sta. Cruz with help from contributors (list).

ricostacruz.com  · 
GitHub @rstacruz  · 
Twitter @rstacruz

 

主要指标

概览
名称与所有者rstacruz/remount
主编程语言JavaScript
编程语言JavaScript (语言数: 2)
平台
许可证MIT License
所有者活动
创建于2018-08-16 10:57:39
推送于2023-03-08 07:41:22
最后一次提交2022-09-30 20:50:26
发布数21
最新版本名称v1.0.0 (发布于 2022-09-30 20:50:26)
第一版名称v0.1.0 (发布于 2018-08-17 17:45:24)
用户参与
星数720
关注者数9
派生数23
提交数291
已启用问题?
问题数13
打开的问题数8
拉请求数20
打开的拉请求数3
关闭的拉请求数57
项目设置
已启用Wiki?
已存档?
是复刻?
已锁定?
是镜像?
是私有?