mirror of
https://gitee.com/baidu/amis.git
synced 2024-12-02 03:58:07 +08:00
chore: 优化 locale, theme hoc, 存在 context 直接复用 (#5702)
* publish beta * chore: 优化 locale, theme hoc, 存在 context 直接复用
This commit is contained in:
parent
723c6bf4eb
commit
a6592c7d28
@ -128,17 +128,21 @@ export function localeable<
|
||||
const refConfig = ComposedComponent.prototype?.isReactComponent
|
||||
? {ref: this.childRef}
|
||||
: {forwardedRef: this.childRef};
|
||||
return (
|
||||
<LocaleContext.Provider value={locale}>
|
||||
<ComposedComponent
|
||||
{...(this.props as JSX.LibraryManagedAttributes<
|
||||
T,
|
||||
React.ComponentProps<T>
|
||||
> as any)}
|
||||
{...injectedProps}
|
||||
{...refConfig}
|
||||
/>
|
||||
</LocaleContext.Provider>
|
||||
|
||||
const body = (
|
||||
<ComposedComponent
|
||||
{...(this.props as JSX.LibraryManagedAttributes<
|
||||
T,
|
||||
React.ComponentProps<T>
|
||||
> as any)}
|
||||
{...injectedProps}
|
||||
{...refConfig}
|
||||
/>
|
||||
);
|
||||
return this.context ? (
|
||||
body
|
||||
) : (
|
||||
<LocaleContext.Provider value={locale}>{body}</LocaleContext.Provider>
|
||||
);
|
||||
}
|
||||
},
|
||||
|
@ -191,18 +191,22 @@ export function themeable<
|
||||
? {ref: this.childRef}
|
||||
: {forwardedRef: this.childRef};
|
||||
|
||||
return (
|
||||
<ThemeContext.Provider value={theme}>
|
||||
<ComposedComponent
|
||||
{...config.getComponentConfig(ComposedComponent.themeKey)}
|
||||
{...(this.props as JSX.LibraryManagedAttributes<
|
||||
T,
|
||||
React.ComponentProps<T>
|
||||
>)}
|
||||
{...injectedProps}
|
||||
{...refConfig}
|
||||
/>
|
||||
</ThemeContext.Provider>
|
||||
const body = (
|
||||
<ComposedComponent
|
||||
{...config.getComponentConfig(ComposedComponent.themeKey)}
|
||||
{...(this.props as JSX.LibraryManagedAttributes<
|
||||
T,
|
||||
React.ComponentProps<T>
|
||||
>)}
|
||||
{...injectedProps}
|
||||
{...refConfig}
|
||||
/>
|
||||
);
|
||||
|
||||
return this.context ? (
|
||||
body
|
||||
) : (
|
||||
<ThemeContext.Provider value={theme}>{body}</ThemeContext.Provider>
|
||||
);
|
||||
}
|
||||
},
|
||||
|
Loading…
Reference in New Issue
Block a user