@mpxjs/webpack-plugin 2.9.69-beta.11 → 2.9.69-beta.12

This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
@@ -1,9 +1,10 @@
1
+ import { useContext } from 'react';
1
2
  import { PortalContext, VarContext } from './context';
2
3
  import PortalConsumer from './mpx-portal/portal-consumer';
3
4
  import PortalHost, { portal } from './mpx-portal/portal-host';
4
- const Portal = ({ children, varContext }) => {
5
- const hasVarContext = varContext && Object.keys(varContext).length;
6
- if (hasVarContext) {
5
+ const Portal = ({ children }) => {
6
+ const varContext = useContext(VarContext);
7
+ if (varContext) {
7
8
  children = (<VarContext.Provider value={varContext} key='varContextWrap'>{children}</VarContext.Provider>);
8
9
  }
9
10
  return (<PortalContext.Consumer>
@@ -1,18 +1,16 @@
1
1
  /**
2
2
  * ✔ enable
3
3
  */
4
- import { createElement, Fragment, useContext } from 'react';
4
+ import { createElement, Fragment } from 'react';
5
5
  import Portal from './mpx-portal';
6
6
  import { warn } from '@mpxjs/utils';
7
- import { VarContext } from './context';
8
7
  const _RootPortal = (props) => {
9
8
  const { children, enable = true } = props;
10
9
  if (props.style) {
11
10
  warn('The root-portal component does not support the style prop.');
12
11
  }
13
- const varContext = useContext(VarContext);
14
12
  return enable
15
- ? createElement(Portal, { varContext }, children)
13
+ ? createElement(Portal, null, children)
16
14
  : createElement(Fragment, null, children);
17
15
  };
18
16
  _RootPortal.displayName = 'MpxRootPortal';
@@ -1,4 +1,4 @@
1
- import { ReactNode } from 'react'
1
+ import { ReactNode, useContext } from 'react'
2
2
  import { PortalContext, PortalContextValue, VarContext } from './context'
3
3
  import PortalConsumer from './mpx-portal/portal-consumer'
4
4
  import PortalHost, { portal } from './mpx-portal/portal-host'
@@ -13,10 +13,10 @@ export type PortalProps = {
13
13
  varContext?: Record<string, any> | undefined
14
14
  }
15
15
 
16
- const Portal = ({ children, varContext }:PortalProps): JSX.Element => {
17
- const hasVarContext = varContext && Object.keys(varContext).length
18
- if (hasVarContext) {
19
- children = (<VarContext.Provider value={varContext} key='varContextWrap'>{children}</VarContext.Provider>)
16
+ const Portal = ({ children }:PortalProps): JSX.Element => {
17
+ const varContext = useContext(VarContext)
18
+ if (varContext) {
19
+ children = (<VarContext.Provider value={varContext} key='varContextWrap'>{children}</VarContext.Provider>)
20
20
  }
21
21
  return (
22
22
  <PortalContext.Consumer>
@@ -1,7 +1,7 @@
1
1
  /**
2
2
  * ✔ enable
3
3
  */
4
- import { ReactNode, createElement, Fragment, useContext } from 'react'
4
+ import { ReactNode, createElement, Fragment } from 'react'
5
5
  import Portal from './mpx-portal'
6
6
  import { warn } from '@mpxjs/utils'
7
7
  import { VarContext } from './context'
@@ -16,9 +16,9 @@ const _RootPortal = (props: RootPortalProps) => {
16
16
  if (props.style) {
17
17
  warn('The root-portal component does not support the style prop.')
18
18
  }
19
- const varContext = useContext(VarContext)
19
+
20
20
  return enable
21
- ? createElement(Portal, { varContext }, children)
21
+ ? createElement(Portal, null, children)
22
22
  : createElement(Fragment, null, children)
23
23
  }
24
24
 
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "@mpxjs/webpack-plugin",
3
- "version": "2.9.69-beta.11",
3
+ "version": "2.9.69-beta.12",
4
4
  "description": "mpx compile core",
5
5
  "keywords": [
6
6
  "mpx"