This file contains hidden or 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
/* ... */ | |
import Bar from './bar'; | |
class Foo extends React.Component { | |
/* ... */ | |
render() { | |
return ( | |
<Bar /> |
This file contains hidden or 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
/* ... */ | |
class Foo extends React.Component { | |
/* ... */ | |
render() { | |
if (this.props.shouldDrawFoo) { | |
return ( | |
<div className="foo"> |
This file contains hidden or 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
/* ... */ | |
import React from 'react'; | |
import { shallow } from 'enzyme'; | |
class Foo extends React.Component { | |
_something() { | |
/* DO SOMETHING */ | |
} | |
render() { |
This file contains hidden or 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
/* ... */ | |
import { shallow } from 'enzyme'; | |
describe('<Foo />', () => { | |
it('should render one <div>', () => { | |
const wrapper = shallow(<Foo />); | |
expect(wrapper.find('div')).to.have.lengthOf(1); | |
}); | |
}); |
This file contains hidden or 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
import React, { PropTypes } from 'react'; | |
import SomeComponent from 'components/SomeComponent/async'; | |
export const App = () => ( | |
<SomeComponent someProp={/* ... */} /> | |
) |
This file contains hidden or 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
import React, { PropTypes } from 'react'; | |
import SomeComponent from 'components/SomeComponent'; | |
export const App = () => ( | |
<SomeComponent someProp={/* ... */} /> | |
) |
This file contains hidden or 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
import React from 'react'; | |
import AsyncComponent from 'components/AsyncComponent'; | |
const loader = () => import(/* webpackChunkName: "Some" */'components/SomeComponent'); | |
export default props => <AsyncComponent {...props} loader={loader} />; |
This file contains hidden or 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
import SyncComponent from './SyncComponent'; | |
// Dynamic import | |
const dynamicImportPromise = import('./AsyncComponent'); | |
dynamicImportPromise.then((module) => { | |
/* DO SOMETHING */ | |
} |
This file contains hidden or 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
import React, { PropTypes } from 'react'; | |
import AsyncComponent from './AsyncComponent'; | |
export const App = () => ( | |
<AsyncComponent loader={() => import('components/SomeComponent')} /> | |
) |
This file contains hidden or 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
import React, { PropTypes } from 'react'; | |
export default class AsyncComponent extends React.Component { | |
static propTypes = { | |
loader: PropTypes.func.isRequired, | |
} | |
state = { | |
Component: null, | |
} |