Skip to content

Commit e10bf72

Browse files
committed
Use componentDidMount and componentDidUpdate for render theme
1 parent c492b2e commit e10bf72

File tree

1 file changed

+8
-2
lines changed

1 file changed

+8
-2
lines changed

src/components/RootThemeContainer.js

Lines changed: 8 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -11,9 +11,15 @@ class RootThemeContainer extends React.Component {
1111
theme: PropTypes.instanceOf(Theme).isRequired,
1212
}
1313

14+
componentDidMount() {
15+
document.documentElement.className = `Theme__${this.props.theme.id}`;
16+
}
17+
18+
componentDidUpdate() {
19+
document.documentElement.className = `Theme__${this.props.theme.id}`;
20+
}
21+
1422
render() {
15-
const { theme } = this.props;
16-
document.documentElement.className = `Theme__${theme.id}`;
1723
return null;
1824
}
1925
}

0 commit comments

Comments
 (0)