Skip to content

Instantly share code, notes, and snippets.

@ninjaPixel
Last active August 10, 2018 17:56
Show Gist options
  • Star 0 You must be signed in to star a gist
  • Fork 0 You must be signed in to fork a gist
  • Save ninjaPixel/41f78d1fd01ed4b81759e21229ccb3cf to your computer and use it in GitHub Desktop.
Save ninjaPixel/41f78d1fd01ed4b81759e21229ccb3cf to your computer and use it in GitHub Desktop.
Our 'Test' component. It pulls in some external libs, bloating our Meteor app
import React from 'react';
import PropTypes from 'prop-types';
import { withStyles, Typography } from '@material-ui/core';
import moment from 'moment';
import _ from 'lodash';
const Test = (props) => {
const { classes, name } = props;
const lodash = _.get({}, 'x', true);
console.log('lodash: ', lodash);
const x = _.cloneDeep({ hello: 'world!' });
const time = new moment();
return (
<div className={classes.root}>
<Typography variant="display1" >Hello, {name}!</Typography>
<Typography>This component depends upon the material-ui, moment, and lodash libraries.</Typography>
<Typography>These libraries are loaded dynamically, which means that they are kept out of the initial client bundle️, which reduces the bundle size significantly.</Typography>
<Typography>Current date (calculated by moment.js): {time.toString()}</Typography>
</div>
);
};
const style = theme => ({
root: {
padding: theme.spacing.unit * 10,
height:150,
backgroundColor: 'yellow',
},
});
export default withStyles(style)(Test);
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment