-
-
Notifications
You must be signed in to change notification settings - Fork 32.4k
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
[withWidth] Document the render prop (#13074)
* 📝 render props doc for withWidth * well done
- Loading branch information
1 parent
d458811
commit a34a2a5
Showing
3 changed files
with
30 additions
and
0 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,16 @@ | ||
import React from 'react'; | ||
import withWidth from '@material-ui/core/withWidth'; | ||
import Typography from '@material-ui/core/Typography'; | ||
import toRenderProps from 'recompose/toRenderProps'; | ||
|
||
const WithWidth = toRenderProps(withWidth()); | ||
|
||
function RenderPropsWithWidth() { | ||
return ( | ||
<WithWidth> | ||
{({ width }) => <Typography variant="subtitle1">Current width: {width}</Typography>} | ||
</WithWidth> | ||
); | ||
} | ||
|
||
export default RenderPropsWithWidth; |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters