Skip to content

Instantly share code, notes, and snippets.

@agupta93
Created October 21, 2018 05:05
Show Gist options
  • Save agupta93/0db3b635f0073ecac96ada9e273eef9a to your computer and use it in GitHub Desktop.
Save agupta93/0db3b635f0073ecac96ada9e273eef9a to your computer and use it in GitHub Desktop.
import React, {Component} from 'react';
import Table from './Table';
import Card from './Card';
class Controller extends Component {
state = {
view: 'list'
}
switchToCardView = () => {
this.setState({
view: 'card'
})
}
render() {
//... Some implementation
if (this.state.view === 'list') {
return <Table {...this.props} />
}
return <Card {...this.props} />
}
}
export default Controller;
import React, {Component} from 'react';
class Table extends Component {
state = {
page: 0,
filters: []
}
render() {
// ... Some implementation
}
}
export default Table;
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment