chore: rename internal Affix (#40838)

This commit is contained in:
lijianan 2023-02-22 10:42:25 +08:00 committed by GitHub
parent bce4245d4f
commit f9a38af179
No known key found for this signature in database
GPG Key ID: 4AEE18F83AFDEB23
2 changed files with 12 additions and 8 deletions

View File

@ -53,7 +53,7 @@ export interface AffixState {
prevTarget: Window | HTMLElement | null;
}
class Affix extends React.Component<InternalAffixProps, AffixState> {
class InternalAffix extends React.Component<InternalAffixProps, AffixState> {
static contextType = ConfigContext;
state: AffixState = {
@ -293,9 +293,9 @@ class Affix extends React.Component<InternalAffixProps, AffixState> {
}
}
// just use in test
export type InternalAffixClass = Affix;
export type InternalAffixClass = InternalAffix;
const AffixFC = forwardRef<Affix, AffixProps>((props, ref) => {
const Affix = forwardRef<InternalAffix, AffixProps>((props, ref) => {
const { prefixCls: customizePrefixCls, rootClassName } = props;
const { getPrefixCls } = useContext<ConfigConsumerProps>(ConfigContext);
const affixPrefixCls = getPrefixCls('affix', customizePrefixCls);
@ -308,11 +308,11 @@ const AffixFC = forwardRef<Affix, AffixProps>((props, ref) => {
rootClassName: classNames(rootClassName, hashId),
};
return wrapSSR(<Affix {...AffixProps} ref={ref} />);
return wrapSSR(<InternalAffix {...AffixProps} ref={ref} />);
});
if (process.env.NODE_ENV !== 'production') {
AffixFC.displayName = 'Affix';
Affix.displayName = 'Affix';
}
export default AffixFC;
export default Affix;

View File

@ -1,4 +1,5 @@
import addEventListener from 'rc-util/lib/Dom/addEventListener';
import type { InternalAffixClass } from '.';
export type BindElement = HTMLElement | Window | null | undefined;
@ -51,7 +52,10 @@ export function getObserverEntities() {
return observerEntities;
}
export function addObserveTarget<T>(target: HTMLElement | Window | null, affix?: T): void {
export function addObserveTarget<T extends InternalAffixClass>(
target: HTMLElement | Window | null,
affix?: T,
): void {
if (!target) {
return;
}
@ -79,7 +83,7 @@ export function addObserveTarget<T>(target: HTMLElement | Window | null, affix?:
}
}
export function removeObserveTarget<T>(affix: T): void {
export function removeObserveTarget<T extends InternalAffixClass>(affix: T): void {
const observerEntity = observerEntities.find((oriObserverEntity) => {
const hasAffix = oriObserverEntity.affixList.some((item) => item === affix);
if (hasAffix) {