This plugin will provide drop in support for "just works" server side rendering material-ui
components.
yarn add fusion-plugin-material-ui
// ButtonWrap.js
import React from 'react';
import Button from '@material-ui/core/Button';
export ButtonWrap = () => (
<Button
variant="contained"
color="primary"
>
with bacon
</Button>
)
// main.js
import React from 'react';
import App from 'fusion-react';
import MuiThemeProvider, {
MuiThemeProviderToken,
} from 'fusion-plugin-material-ui';
export default () => {
const app = new App(root);
// will use the default theme
app.register(MuiThemeProviderToken, MuiThemeProvider);
return app;
};
https://material-ui.com/customization/themes/
// main.js
import React from 'react';
import App from 'fusion-react';
import MuiThemeProvider, {
MuiThemeProviderToken,
MuiThemeToken,
} from 'fusion-plugin-material-ui';
import {createMuiTheme} from '@material-ui/core/styles';
export default () => {
const app = new App(root);
app.register(MuiThemeToken, createMuiTheme({fooColor: '#ba4'}));
app.register(MuiThemeProviderToken, MuiThemeProvider);
return app;
};
import MuiThemeProvider from 'fusion-plugin-material-ui';
Adds the MuiThemeProvider
from @material-ui/core
and handles server side rendering. Typically registered with MuiThemeProviderToken
import {MuiThemeProviderToken} from 'fusion-plugin-material-ui';
Typicall registered with MuiThemeProvider
import {MuiThemeToken} from 'fusion-plugin-material-ui';
Register with your own custom material-ui
theme.
Optional
import {JssToken} from 'fusion-plugin-material-ui';
Register with your own custom jss
instance.
Optional
This requires management of a custom jss
instance.
https://material-ui.com/customization/css-in-js/
// main.js
import React from 'react';
import App from 'fusion-react';
import {create} from 'jss';
import MuiThemeProvider, {
JssToken,
MuiThemeProviderToken,
} from 'fusion-plugin-material-ui';
export default () => {
const app = new App(root);
app.register(JssToken, create());
app.register(MuiThemeProviderToken, MuiThemeProvider);
return app;
};