Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

[docs] Fix codesandbox examples with React Hooks #14116

Merged
merged 3 commits into from Jan 8, 2019
Merged
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Jump to
Jump to file
Failed to load files.
Diff view
Diff view
26 changes: 25 additions & 1 deletion docs/src/modules/components/Demo.js
Expand Up @@ -38,7 +38,7 @@ function addHiddenInput(form, name, value) {
}

function getDemo(props, raw) {
return {
const demo = {
title: 'Material demo',
description: props.githubLocation,
dependencies: getDependencies(raw, props.demoOptions.react),
Expand All @@ -60,6 +60,30 @@ ReactDOM.render(<Demo />, document.querySelector('#root'));
`,
},
};

if (props.codeVariant === CODE_VARIANTS.HOOK) {
demo.dependencies.react = 'next';
demo.dependencies['react-dom'] = 'next';
demo.dependencies['@material-ui/styles'] = 'latest';
demo.files['index.js'] = `
import React from 'react';
import ReactDOM from 'react-dom';
import Demo from './demo';
import { createMuiTheme } from "@material-ui/core/styles";
import { ThemeProvider } from "@material-ui/styles";

const theme = createMuiTheme();

ReactDOM.render(
<ThemeProvider theme={theme}>
<Demo />
</ThemeProvider>,
document.querySelector("#root")
);
`;
}

return demo;
}

const styles = theme => ({
Expand Down