File tree 2 files changed +31
-1
lines changed
docs/src/pages/styles/advanced
2 files changed +31
-1
lines changed Original file line number Diff line number Diff line change @@ -7,7 +7,9 @@ function DeepChildRaw(props) {
7
7
}
8
8
9
9
DeepChildRaw . propTypes = {
10
- theme : PropTypes . object . isRequired ,
10
+ theme : PropTypes . shape ( {
11
+ spacing : PropTypes . string . isRequired ,
12
+ } ) . isRequired ,
11
13
} ;
12
14
13
15
const DeepChild = withTheme ( DeepChildRaw ) ;
Original file line number Diff line number Diff line change
1
+ import React from 'react' ;
2
+ import { ThemeProvider , WithTheme as WithThemeProps , withTheme } from '@material-ui/styles' ;
3
+
4
+ interface Theme {
5
+ spacing : string ;
6
+ }
7
+
8
+ interface Props extends WithThemeProps < Theme > { }
9
+
10
+ function DeepChildRaw ( props : Props ) {
11
+ return < span > { `spacing ${ props . theme . spacing } ` } </ span > ;
12
+ }
13
+
14
+ const DeepChild = withTheme < Theme , typeof DeepChildRaw > ( DeepChildRaw ) ;
15
+
16
+ function WithTheme ( ) {
17
+ return (
18
+ < ThemeProvider
19
+ theme = { {
20
+ spacing : '8px' ,
21
+ } }
22
+ >
23
+ < DeepChild />
24
+ </ ThemeProvider >
25
+ ) ;
26
+ }
27
+
28
+ export default WithTheme ;
You can’t perform that action at this time.
0 commit comments