import React from 'react'; import { act } from '@testing-library/react'; import { HotTable } from '../src/hotTable'; import { createSpreadsheetData, mockElementDimensions, mountComponentWithRef, sleep, } from './_helpers'; /** * Worth noting, that although it's possible to use React.memo on renderer components, it doesn't do much, as currently they're recreated on every * Handsontable's `render`. */ describe('React.memo', () => { it('should be possible to use React.memo on renderer components.', async () => { function RendererComponent2 (props) { return ( <> value: {props.value} ); } const MemoizedRendererComponent2 = React.memo(RendererComponent2); const hotInstance = mountComponentWithRef(( )).hotInstance; await act(async () => { hotInstance.render(); }); await sleep(100); expect(hotInstance.getCell(0, 0).innerHTML).toEqual('
value: A1
'); }); /* Editors cannot use React.memo, as they're derived from the BaseEditorComponent class, thus not being function components. */ });