Skip to content

Commit

Permalink
Merge pull request #1490 from gluestack/fix/config-reference
Browse files Browse the repository at this point in the history
Fix/config reference
  • Loading branch information
ankit-tailor authored Dec 13, 2023
2 parents 9241d6e + f612307 commit 95a864e
Showing 1 changed file with 16 additions and 2 deletions.
18 changes: 16 additions & 2 deletions packages/styled/react/src/StyledProvider.tsx
Original file line number Diff line number Diff line change
Expand Up @@ -6,6 +6,7 @@ import type { COLORMODES } from './types';
import { platformSpecificSpaceUnits } from './utils';
import { createGlobalStylesWeb } from './createGlobalStylesWeb';
import { createGlobalStyles } from './createGlobalStyles';
import { deepClone } from './utils/cssify/utils/common';

type Config = any;
let colorModeSet = false;
Expand Down Expand Up @@ -57,8 +58,21 @@ export const StyledProvider: React.FC<{
inlineStyleMap.current.initialStyleInjected = false;

const currentConfig: any = React.useMemo(() => {
//TODO: Add this later
return platformSpecificSpaceUnits(config, Platform.OS);
// Removing plugins since its array and deepClone is not working
const plugins = config?.plugins;
delete config?.plugins;

const clonedConfig = deepClone(config);
const configWithPlatformSpecificUnits: any = platformSpecificSpaceUnits(
clonedConfig,
Platform.OS
);

// Re-assign plugins to both the configs
configWithPlatformSpecificUnits.plugins = plugins;
config.plugins = plugins;

return configWithPlatformSpecificUnits;
}, [config]);

if (Platform.OS === 'web' && globalStyles) {
Expand Down

0 comments on commit 95a864e

Please sign in to comment.