0.0.22 • Published 2 years ago

common-master-mfe-integration v0.0.22

Weekly downloads
-
License
ISC
Repository
github
Last release
2 years ago

use-web-component

1.Reason

hook to integrate web component in minutes

we have these web-components:

  - project-master
  - department-master

2.React tutorial

  • install
  yarn add common-master-mfe-integration
  • define remote main.js,
  • tag name: important !, tag name must be right
  • bridge: data that need to transfer from host app to remote app
  • input types and hook can get from this npm
import { useProjectMaster } from 'common-master-mfe-integration'

const bridge = {
  axios, fetch, routerFn, permissions, ...
}

export default function Page() {
  const [WebComponent] = useProjectMaster('http://localhost:3002/main.js', bridge)
  return <WebComponent title="1" name="2" />
}

3.Issues:

3.1.Missing ES5 class

  • you can see this error :
Uncaught TypeError: Failed to construct 'HTMLElement': Please use the 'new' operator, this DOM object constructor cannot be called as a function.
  • Add this polyfill into head of html to fix:
<script src="https://unpkg.com/@webcomponents/webcomponentsjs@2.0.3/custom-elements-es5-adapter.js"></script>
  • if you use react and hook of this lib: useWebComponent, useProjectMaster, useDepartmentMaster, ... you don't need to add this polyfill manually
0.0.22

2 years ago

0.0.21

2 years ago

0.0.20

2 years ago

0.0.19

2 years ago

0.0.18

2 years ago

0.0.17

2 years ago

0.0.16

2 years ago

0.0.15

2 years ago

0.0.14

2 years ago

0.0.13

2 years ago

0.0.12

2 years ago

0.0.11

2 years ago

0.0.10

2 years ago

0.0.9

2 years ago

0.0.8

2 years ago

0.0.7

2 years ago

0.0.6

2 years ago

0.0.5

2 years ago

0.0.4

2 years ago

0.0.3

2 years ago

0.0.2

2 years ago