Clear FormWrapper warnings, remove shouldCompUpdate & make it PureFunction

This commit is contained in:
Luca Hagel 2018-01-06 08:38:14 +01:00
parent 902680df47
commit 97116235fa

View file

@ -24,7 +24,7 @@ component is also added to wait for withDocument's loading prop to be false)
*/ */
import React, { Component } from 'react'; import React, { PureComponent } from 'react';
import PropTypes from 'prop-types'; import PropTypes from 'prop-types';
import { intlShape } from 'meteor/vulcan:i18n'; import { intlShape } from 'meteor/vulcan:i18n';
import { withApollo, compose } from 'react-apollo'; import { withApollo, compose } from 'react-apollo';
@ -34,7 +34,7 @@ import gql from 'graphql-tag';
import { withDocument } from 'meteor/vulcan:core'; import { withDocument } from 'meteor/vulcan:core';
import { graphql } from 'react-apollo'; import { graphql } from 'react-apollo';
class FormWrapper extends Component { class FormWrapper extends PureComponent {
constructor(props) { constructor(props) {
super(props); super(props);
@ -216,12 +216,6 @@ class FormWrapper extends Component {
} }
} }
shouldComponentUpdate(nextProps) {
// prevent extra re-renderings for unknown reasons
// re-render only if the document selector changes
return nextProps.slug !== this.props.slug || nextProps.documentId !== this.props.documentId;
}
render() { render() {
return this.FormComponent; return this.FormComponent;
} }
@ -266,12 +260,4 @@ FormWrapper.contextTypes = {
intl: intlShape intl: intlShape
} }
FormWrapper.childContextTypes = {
autofilledValues: PropTypes.object,
addToAutofilledValues: PropTypes.func,
updateCurrentValues: PropTypes.func,
throwError: PropTypes.func,
getDocument: PropTypes.func
}
registerComponent('SmartForm', FormWrapper, withCurrentUser, withApollo); registerComponent('SmartForm', FormWrapper, withCurrentUser, withApollo);