Skip to content

Commit 9a6636c

Browse files
authored
Merge pull request #65 from aquaductape/have-ref-prop
Include ref prop on Repl Component
2 parents 00f3cfd + 3e5f6c3 commit 9a6636c

File tree

2 files changed

+8
-1
lines changed

2 files changed

+8
-1
lines changed

src/components/repl.tsx

Lines changed: 7 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -42,6 +42,7 @@ export interface ReplProps {
4242
current: string;
4343
setCurrent: (tabId: string) => void;
4444
onEditorReady?: (editor: mEditor.IStandaloneCodeEditor) => unknown;
45+
ref?: HTMLDivElement | ((el: HTMLDivElement) => void);
4546
}
4647

4748
export const Repl: Component<ReplProps> = (props) => {
@@ -263,7 +264,12 @@ export const Repl: Component<ReplProps> = (props) => {
263264

264265
return (
265266
<div
266-
ref={(el) => setGrid(el)}
267+
ref={(el) => {
268+
setGrid(el);
269+
if (props.ref) {
270+
(props.ref as (el: HTMLDivElement) => void)(el);
271+
}
272+
}}
267273
class="relative grid bg-blueGray-50 h-full overflow-hidden text-blueGray-900 dark:text-blueGray-50 font-sans"
268274
classList={{
269275
'wrapper--forced': props.isHorizontal,

types/types.d.ts

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -16,6 +16,7 @@ export declare const Repl: Component<{
1616
current: string;
1717
setCurrent: (tabId: string) => void;
1818
onEditorReady?: (editor: mEditor.IStandaloneCodeEditor) => unknown;
19+
ref?: HTMLDivElement | ((el: HTMLDivElement) => void);
1920
}>;
2021

2122
export interface Tab {

0 commit comments

Comments
 (0)