diff --git a/packages/browser-repl/src/components/shell.tsx b/packages/browser-repl/src/components/shell.tsx index cfd7026ee..35c2ad510 100644 --- a/packages/browser-repl/src/components/shell.tsx +++ b/packages/browser-repl/src/components/shell.tsx @@ -462,10 +462,11 @@ export class _Shell extends Component { type DefaultProps = keyof (typeof _Shell)['defaultProps']; -export const Shell = function ShellWithDarkMode( - props: Omit & +export const Shell = React.forwardRef< + _Shell, + Omit & Partial> -) { +>(function ShellWithDarkMode(props, ref) { const darkMode = useDarkMode(); - return <_Shell darkMode={darkMode} {...props}>; -}; + return <_Shell darkMode={darkMode} ref={ref} {...props}>; +}); diff --git a/packages/browser-repl/src/index.spec.tsx b/packages/browser-repl/src/index.spec.tsx new file mode 100644 index 000000000..0d5783bea --- /dev/null +++ b/packages/browser-repl/src/index.spec.tsx @@ -0,0 +1,14 @@ +import React from 'react'; +import { Shell } from './index'; +import { expect } from '../testing/chai'; +import { mount } from '../testing/enzyme'; + +describe('Shell', function () { + it('should provide access to ref', function () { + const ref = React.createRef(); + mount(); + expect(ref.current).to.have.property('state'); + expect(ref.current).to.have.property('props'); + expect(ref.current).to.have.property('editor'); + }); +});