Skip to content

Commit

Permalink
fix: fix flawed styled.one() caching
Browse files Browse the repository at this point in the history
  • Loading branch information
jaredLunde committed Oct 9, 2021
1 parent a52d1ab commit d551e15
Showing 1 changed file with 10 additions and 14 deletions.
24 changes: 10 additions & 14 deletions src/index.tsx
Original file line number Diff line number Diff line change
Expand Up @@ -129,22 +129,18 @@ export function createStyles<
| StyleCallback<S, ValueOf<Omit<VT, "default">>>,
...placeholders: string[]
) {
let styles = compileStyles(
compileLiterals(literals, ...placeholders),
tokens[currentTheme]
);
const compiledLiterals = compileLiterals(literals, ...placeholders);

if (process.env.NODE_ENV !== "production") {
styles = Object.freeze(styles);
}
return function oneStyle(createStyle?: unknown): S {
if (!createStyle && createStyle !== void 0) return emptyObj as S;
let styles = compileStyles(compiledLiterals, tokens[currentTheme]);

return Object.assign(
function oneStyle(createStyle?: unknown): S {
if (!createStyle && createStyle !== void 0) return emptyObj as S;
return styles;
},
{ styles }
);
if (process.env.NODE_ENV !== "production") {
styles = Object.freeze(styles);
}

return styles;
};
},
cls,
lazy<Value extends JsonValue, S extends RNStyles = RNStyles>(
Expand Down

0 comments on commit d551e15

Please sign in to comment.