Skip to content

Commit

Permalink
fix: 防止多余字段污染临时配置
Browse files Browse the repository at this point in the history
  • Loading branch information
BastKakrolot committed Nov 16, 2023
1 parent c6b395c commit d9bbe39
Showing 1 changed file with 5 additions and 2 deletions.
7 changes: 5 additions & 2 deletions packages/hooks/src/useRequest/src/Fetch.ts
Original file line number Diff line number Diff line change
Expand Up @@ -11,7 +11,7 @@ import type {
TempConfig,
} from './types';
import { Trigger } from './types';
import { omit } from 'lodash-es';
import { pick, keys } from 'lodash-es';

const getDefaultTempConfig: () => TempConfig = () => ({
trigger: undefined,
Expand Down Expand Up @@ -56,7 +56,10 @@ export default class Fetch<TData, TParams extends any[]> {
this.tempConfig = {
...this.tempConfig,
// 不允许修改触发器类型
...omit(config, 'trigger'),
...pick(
config,
keys(getDefaultTempConfig()).filter((key) => key !== 'trigger'),
),
};
}
getTempConfig(key: keyof TempConfig | undefined) {
Expand Down

0 comments on commit d9bbe39

Please sign in to comment.