Browse Source

chore: dynamic salt on dev env (#35120)

pull/35127/head
二货机器人 3 years ago
committed by GitHub
parent
commit
c4dab10188
No known key found for this signature in database GPG Key ID: 4AEE18F83AFDEB23
  1. 7
      components/_util/theme/index.tsx

7
components/_util/theme/index.tsx

@ -73,6 +73,11 @@ export const DesignTokenContext = React.createContext<{
});
// ================================== Hook ==================================
// In dev env, we refresh salt per hour to avoid user use this
// Note: Do not modify this to real time update which will make debug harder
const saltPrefix =
process.env.NODE_ENV === 'production' ? version : `${version}-${new Date().getHours()}`;
export function useToken(): [Theme<SeedToken, DerivativeToken>, GlobalToken, string] {
const {
token: rootDesignToken,
@ -81,7 +86,7 @@ export function useToken(): [Theme<SeedToken, DerivativeToken>, GlobalToken, str
hashed,
} = React.useContext(DesignTokenContext);
const salt = `${version}-${hashed || ''}`;
const salt = `${saltPrefix}-${hashed || ''}`;
const [token, hashId] = useCacheToken<GlobalToken, SeedToken>(
theme,

Loading…
Cancel
Save