Skip to content

Commit

Permalink
fix: fix static style memory leak
Browse files Browse the repository at this point in the history
  • Loading branch information
streamich committed Feb 12, 2018
1 parent 44f944b commit b8900e2
Show file tree
Hide file tree
Showing 3 changed files with 22 additions and 9 deletions.
9 changes: 9 additions & 0 deletions .storybook/css/StoryStatic.tsx
Original file line number Diff line number Diff line change
Expand Up @@ -82,3 +82,12 @@ export class Button extends Component<any, any> {
return <button>Hello world!</button>;
}
}

/*@css
export class Button extends Compnent<any, any> {
static css
render () {
}
}
*/
2 changes: 1 addition & 1 deletion package.json
Original file line number Diff line number Diff line change
@@ -1,6 +1,6 @@
{
"name": "freestyler",
"version": "1.6.0",
"version": "1.6.3",
"description": "5th generation React styling library",
"main": "lib/index.js",
"module": "modules/index.js",
Expand Down
20 changes: 12 additions & 8 deletions src/renderer/Renderer.ts
Original file line number Diff line number Diff line change
Expand Up @@ -389,12 +389,14 @@ class Renderer implements IRenderer {
}

unrender(Comp, instance, el: HTMLElement | null) {
require('../debug').emit({
type: 'UNRENDER',
Comp,
instance,
el,
});
if (process.env.NODE_ENV !== 'production') {
require('../debug').emit({
type: 'UNRENDER',
Comp,
instance,
el,
});
}

// Remove statics
const cacheMap = instance[$$statics] as {[key: string]: DeclarationCache};
Expand All @@ -412,8 +414,8 @@ class Renderer implements IRenderer {
if (dynamics) {
dynamics.destroy();
// TODO: Do we really need this line?
instance[$$dynamics] = null;
// delete instance[$$dynamics];
// instance[$$dynamics] = null;
delete instance[$$dynamics];
}
}

Expand All @@ -422,6 +424,8 @@ class Renderer implements IRenderer {

if (classNames === void 0) {
hidden(Comp, $$cn, '');
} else {
return classNames;
}

let styles = tplToStyles(tpl, args);
Expand Down

0 comments on commit b8900e2

Please sign in to comment.