10 examples of 'component should update' in JavaScript

Every line of 'component should update' code snippets is scanned for vulnerabilities by our powerful machine learning engine that combs millions of open source libraries, ensuring your JavaScript code is secure.

All examples are scanned by Snyk Code

By copying the Snyk Code Snippets you agree to
27function shouldComponentUpdate(componentType, updateComponentTypeArr) {
28 if (updateComponentTypeArr.includes(componentType)) {
29 return true;
30 } else {
31 return updateComponentTypeArr.includes(/* All */1);
32 }
33}
27shouldComponentUpdate() {
28 return React.addons.PureRenderMixin.shouldComponentUpdate.apply(this, arguments);
29}
57public shouldComponentUpdate(nextProps: IProps, nextState: IState) {
58 return (
59 this.props.media.items.length !== nextProps.media.items.length ||
60 this.props.likedByCurrentUser !== nextProps.likedByCurrentUser ||
61 this.state !== nextState
62 );
63}
229update(component, data) {
230 const changes = getChanges(component);
231 if (data.forceUpdate || this.shouldUpdate(component, changes)) {
232 this.willUpdate_(component, changes);
233 this.patch(component);
234 }
235}
29shouldComponentUpdate(nextProps) {
30 return this.view.onPropsUpdate(this.props, nextProps)
31}
202value: function _updateComponent(prevState, nextState, prevProps, nextProps, force) {
203 if (this._unmounted === true) {
204 this._unmounted = false;
205 return false;
206 }
207 if (!isNullOrUndefined(nextProps) && isNullOrUndefined(nextProps.children)) {
208 nextProps.children = prevProps.children;
209 }
210 if (prevProps !== nextProps || prevState !== nextState || force) {
211 if (prevProps !== nextProps) {
212 this._blockRender = true;
213 this.componentWillReceiveProps(nextProps);
214 this._blockRender = false;
215 }
216 var shouldUpdate = this.shouldComponentUpdate(nextProps, nextState);
217
218 if (shouldUpdate !== false) {
219 this._blockSetState = true;
220 this.componentWillUpdate(nextProps, nextState);
221 this._blockSetState = false;
222 this.props = nextProps;
223 this.state = nextState;
224 var node = this.render();
225
226 this.componentDidUpdate(prevProps, prevState);
227 return node;
228 }
229 }
230}
232Connect.prototype.shouldComponentUpdate = function shouldComponentUpdate(nextProps, nextState) {
233 if (!pure) {
234 this.updateStateProps(nextProps);
235 this.updateDispatchProps(nextProps);
236 this.updateState(nextProps);
237 return true;
238 }
239
240 var storeChanged = nextState.storeState !== this.state.storeState;
241 var propsChanged = !_utilsShallowEqual2['default'](nextProps, this.props);
242 var mapStateProducedChange = false;
243 var dispatchPropsChanged = false;
244
245 if (storeChanged || propsChanged && shouldUpdateStateProps) {
246 mapStateProducedChange = this.updateStateProps(nextProps);
247 }
248
249 if (propsChanged && shouldUpdateDispatchProps) {
250 dispatchPropsChanged = this.updateDispatchProps(nextProps);
251 }
252
253 if (propsChanged || mapStateProducedChange || dispatchPropsChanged) {
254 this.updateState(nextProps);
255 return true;
256 }
257
258 return false;
259 };
7shouldComponentUpdate (nextProps: P, nextState: S) {
8 return !shallowEqual(this.props, nextProps) || !shallowEqual(this.state, nextState)
9}
4shouldComponentUpdate(nextProps) {
5 return nextProps.b !== this.props.b;
6}
43shouldComponentUpdate(nextProps, nextState) {
44// logDiff(this, nextProps, nextState);
45 return !isEqual(nextProps, this.props) ||
46 !isEqual(nextState, this.state);
47 }

Related snippets