Skip to content
Closed
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
7 changes: 6 additions & 1 deletion demo/app.js
Original file line number Diff line number Diff line change
@@ -1,5 +1,10 @@
import React from 'react';

// https://github.com/maicki/why-did-you-update
// NOTE: This slows down performance, even during development
// if (process.env.NODE_ENV !== 'production') {
// const { whyDidYouUpdate } = require('why-did-you-update');
// whyDidYouUpdate(React, { exclude: [ /^HotKeysWrapper/ ] } );
// }
import TranscriptEditor from '../packages/components/transcript-editor';
import SttTypeSelect from './select-stt-json-type';
import ExportFormatSelect from './select-export-format';
Expand Down
1 change: 0 additions & 1 deletion demo/index.module.css
Original file line number Diff line number Diff line change
Expand Up @@ -124,7 +124,6 @@ body {
@media (max-width: 767px) {
body {
padding: 0;
text-align: center;
}

.demoNavItem {
Expand Down
27 changes: 17 additions & 10 deletions demo/select-export-format.js
Original file line number Diff line number Diff line change
@@ -1,16 +1,23 @@
import React from 'react';
import PropTypes from 'prop-types';

const ExportFormatSelect = props => {
return <select className={ props.className } name={ props.name } value={ props.value } onChange={ props.handleChange }>
<option value="draftjs">Draft Js</option>
<option value="txt">Text file</option>
<option value="txtspeakertimecodes">Text file - with Speakers and Timecodes</option>
<option value="html" disabled>HTML</option>
<option value="word" disabled>MS Word</option>
<option value="digitalpaperedit">Digital Paper Edit</option>
</select>;
};
// using PureComponent to minimise number of unnecessary re-renders
class ExportFormatSelect extends React.PureComponent {

render() {
const { props } = this;

return (<select className={ props.className } name={ props.name } value={ props.value } onChange={ props.handleChange }>
<option value="draftjs">Draft Js</option>
<option value="txt">Text file</option>
<option value="txtspeakertimecodes">Text file - with Speakers and Timecodes</option>
<option value="html" disabled>HTML</option>
<option value="word" disabled>MS Word</option>
<option value="digitalpaperedit">Digital Paper Edit</option>
</select>
);
}
}

ExportFormatSelect.propTypes = {
className: PropTypes.string,
Expand Down
330 changes: 330 additions & 0 deletions docs/notes/2019-05-16-prevent-unnecessary-re-renders-in-react.md

Large diffs are not rendered by default.

Loading