mirror of
https://github.com/vale981/Vulcan
synced 2025-03-06 01:51:40 -05:00
Clear FormWrapper warnings, remove shouldCompUpdate & make it PureFunction
This commit is contained in:
parent
902680df47
commit
97116235fa
1 changed files with 2 additions and 16 deletions
|
@ -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);
|
||||||
|
|
Loading…
Add table
Reference in a new issue