react-transcript-editor icon indicating copy to clipboard operation
react-transcript-editor copied to clipboard

Adding test to timed text editor

Open emettely opened this issue 6 years ago • 4 comments

Is your Pull Request request related to another issue in this repository ?

Not from this issue, but DPE has a dependency on react-transcript-editor and we want to start adding tests to it. https://github.com/bbc/digital-paper-edit-electron/issues/4

Describe what the PR does
Adding the most basic test to timed-text-editor and also removing CustomEditor because it's a wrapper component for one single function - we don't really need it.

State whether the PR is ready for review or whether it needs extra work
Ready

Additional context

emettely avatar Sep 17 '19 13:09 emettely

removing CustomEditor

You might want to check this change against this issue https://github.com/bbc/react-transcript-editor/issues/159 (which is the reason why it was initially separated into its own component)

see https://github.com/bbc/react-transcript-editor/pull/160 for more details.

TL;DR: using react inspector tool highlight updates you can see if removing CustomEditor as separate component increases the number of unnecessary re-renders. You'll have to judge it based on colour.

pietrop avatar Sep 17 '19 14:09 pietrop

A very good catch, the re-renders definitely don't happen for the original master. Screen Shot 2019-09-17 at 16 12 52

vs this branch:

Screen Shot 2019-09-17 at 16 14 07

onChange and handleKeyCommand makes the Editor re-render.

emettely avatar Sep 17 '19 15:09 emettely

https://github.com/facebook/react/issues/16437#issuecomment-524892514 The original highlighting function has disappeared but instead you can use the profiler to record the rendering.

emettely avatar Sep 17 '19 15:09 emettely

Added back the Editor as a memoized react component, and now the re-renders are gone. Screen Shot 2019-09-17 at 16 48 32

emettely avatar Sep 17 '19 15:09 emettely