这是indexloc提供的服务,不要输入任何密码
Skip to content

remove legacy react lifecycle methods (fix #99) #208

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

Merged
merged 14 commits into from
Jul 25, 2018
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
3 changes: 0 additions & 3 deletions console/src/components/ApiExplorer/ApiRequest.js
Original file line number Diff line number Diff line change
Expand Up @@ -28,9 +28,6 @@ class ApiRequest extends Component {
this.state.bodyAllowedMethods = ['POST'];
this.state.tabIndex = 0;
this.timer = null;
}

componentWillMount() {
if (this.props.numberOfTables !== 0) {
const graphqlQueryInLS = window.localStorage.getItem('graphiql:query');
if (graphqlQueryInLS && graphqlQueryInLS.indexOf('do not have') !== -1) {
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -8,7 +8,8 @@ import {
} from './AddExistingTableViewActions';

class AddExistingTableView extends Component {
componentWillMount() {
constructor(props) {
super(props);
this.props.dispatch(setDefaults());
}

Expand Down
4 changes: 3 additions & 1 deletion console/src/components/Services/Data/Add/AddTable.js
Original file line number Diff line number Diff line change
Expand Up @@ -51,7 +51,8 @@ const typeDescriptionDict = convertListToDictUsingKV(
);

class AddTable extends Component {
componentWillMount() {
constructor(props) {
super(props);
this.props.dispatch(setDefaults());
const { columns, dispatch } = this.props;
columns.map((column, i) => {
Expand All @@ -65,6 +66,7 @@ class AddTable extends Component {
}
});
}

componentWillUnmount() {
this.props.dispatch(setDefaults());
}
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -12,9 +12,6 @@ import { getRelationshipLine } from '../TableRelationships/Relationships';
import suggestedRelationshipsRaw from '../TableRelationships/autoRelations';

class AutoAddRelations extends Component {
componentWillMount() {
// Initialize
}
trackAllRelations = () => {
this.props.dispatch(autoTrackRelations());
};
Expand Down
3 changes: 2 additions & 1 deletion console/src/components/Services/Data/Schema/Schema.js
Original file line number Diff line number Diff line change
Expand Up @@ -29,7 +29,8 @@ import globals from '../../../../Globals';
const appPrefix = globals.urlPrefix + '/data';

class Schema extends Component {
componentWillMount() {
constructor(props) {
super(props);
// Initialize this table
const dispatch = this.props.dispatch;
dispatch(fetchSchemaList());
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -168,9 +168,6 @@ class FilterQuery extends Component {
dispatch(setDefaultQuery(this.props.curQuery));
}

// componentWillReceiveProps (nextProps) {
// }

render() {
const { dispatch, whereAnd, tableSchema, orderBy } = this.props; // eslint-disable-line no-unused-vars
const styles = require('./FilterQuery.scss');
Expand Down
24 changes: 13 additions & 11 deletions console/src/components/Services/Data/TableBrowseRows/ViewTable.js
Original file line number Diff line number Diff line change
Expand Up @@ -63,15 +63,17 @@ const genRow = (row, headings) => {
};

class ViewTable extends Component {
componentWillMount() {
constructor(props) {
super(props);
// Initialize this table
console.log(props);
this.state = {
dispatch: props.dispatch,
tableName: props.tableName,
};
// this.state.dispatch = props.dispatch;
// this.state.tableName = props.tablename;
const dispatch = this.props.dispatch;
/*
dispatch(setTable(this.props.tableName));
dispatch(vSetDefaults(this.props.tableName));
dispatch(vMakeRequest());
dispatch(fetchTableComment(this.props.tableName));
*/
Promise.all([
dispatch(setTable(this.props.tableName)),
dispatch(vSetDefaults(this.props.tableName)),
Expand All @@ -80,9 +82,9 @@ class ViewTable extends Component {
]);
}

componentWillReceiveProps(nextProps) {
const dispatch = this.props.dispatch;
if (nextProps.tableName !== this.props.tableName) {
static getDerivedStateFromProps(nextProps, prevState) {
const dispatch = prevState.dispatch;
if (nextProps.tableName !== prevState.tableName) {
dispatch(setTable(nextProps.tableName));
dispatch(vSetDefaults(nextProps.tableName));
dispatch(vMakeRequest());
Expand All @@ -97,7 +99,7 @@ class ViewTable extends Component {
);
}

componentWillUpdate() {
getSnapshotBeforeUpdate() {
this.shouldScrollBottom =
window.innerHeight ===
document.body.offsetHeight - document.body.scrollTop;
Expand Down