Skip to content

Commit

Permalink
Task: Adding react-fast-compare to optimise renders
Browse files Browse the repository at this point in the history
  • Loading branch information
jamesdools committed Sep 18, 2019
1 parent 8723a0b commit b6f29c3
Show file tree
Hide file tree
Showing 6 changed files with 11 additions and 8 deletions.
3 changes: 1 addition & 2 deletions package-lock.json

Some generated files are not rendered by default. Learn more about how customized files appear on GitHub.

1 change: 1 addition & 0 deletions package.json
Original file line number Diff line number Diff line change
Expand Up @@ -54,6 +54,7 @@
"mousetrap": "1.5.2",
"number-to-words": "^1.2.4",
"prop-types": "^15.6.2",
"react-fast-compare": "^2.0.4",
"react-keyboard-shortcuts": "^1.1.3",
"react-simple-tooltip": "^2.3.3",
"sbd": "^1.0.15",
Expand Down
4 changes: 3 additions & 1 deletion packages/components/media-player/src/PlaybackRate.js
Original file line number Diff line number Diff line change
@@ -1,13 +1,15 @@
import React from 'react';
import PropTypes from 'prop-types';
import isEqual from 'react-fast-compare';

import Select from './Select';

import style from './PlayerControls/index.module.scss';

class PlaybackRate extends React.Component {

shouldComponentUpdate = (nextProps) => {
return nextProps.playbackRate !== this.props.playbackRate;
return !isEqual(this.props, nextProps);
}

render() {
Expand Down
Original file line number Diff line number Diff line change
@@ -1,11 +1,11 @@
import React from 'react';
import isEqual from 'react-fast-compare';

import style from './index.module.scss';

class TimeBox extends React.Component {

shouldComponentUpdate = (nextProps) => {
return nextProps !== this.props;
return !isEqual(this.props, nextProps);
}

handleClick = (e) => {
Expand Down
3 changes: 2 additions & 1 deletion packages/components/media-player/src/PlayerControls/index.js
Original file line number Diff line number Diff line change
@@ -1,5 +1,6 @@
import React from 'react';
import PropTypes from 'prop-types';
import isEqual from 'react-fast-compare';

import {
faSave,
Expand All @@ -22,7 +23,7 @@ import style from './index.module.scss';
class PlayerControls extends React.Component {

shouldComponentUpdate = (nextProps) => {
return nextProps !== this.props;
return !isEqual(this.props, nextProps);
}

setIntervalHelperBackward = () => {
Expand Down
4 changes: 2 additions & 2 deletions packages/components/media-player/src/ProgressBar.js
Original file line number Diff line number Diff line change
@@ -1,12 +1,12 @@
import React from 'react';
import PropTypes from 'prop-types';
import isEqual from 'react-fast-compare';

import style from './ProgressBar.module.scss';

class ProgressBar extends React.Component {

shouldComponentUpdate = (nextProps) => {
return nextProps !== this.props;
return !isEqual(this.props, nextProps);
}

handleOnChange = (e) => {
Expand Down

0 comments on commit b6f29c3

Please sign in to comment.