Skip to content

Commit 1a57f45

Browse files
committed
fix: react component: Remove checks, because the wrapper performs them already
1 parent e93d21e commit 1a57f45

File tree

1 file changed

+17
-29
lines changed

1 file changed

+17
-29
lines changed

packages/wrapper-react/src/index.tsx

Lines changed: 17 additions & 29 deletions
Original file line numberDiff line numberDiff line change
@@ -57,38 +57,30 @@ export const MonacoEditorReactComp: React.FC<MonacoEditorProps> = (props) => {
5757
}, [wrapperConfig]);
5858

5959
const initMonaco = useCallback(async () => {
60-
if (!wrapperRef.current.isInitializing()) {
61-
if (containerRef.current) {
62-
wrapperConfig.htmlContainer = containerRef.current;
63-
await wrapperRef.current.init(wrapperConfig);
64-
} else {
65-
throw new Error('No htmlContainer found! Aborting...');
66-
}
60+
if (containerRef.current) {
61+
wrapperConfig.htmlContainer = containerRef.current;
62+
await wrapperRef.current.init(wrapperConfig);
6763
} else {
68-
await wrapperRef.current.getInitializingAwait();
64+
throw new Error('No htmlContainer found! Aborting...');
6965
}
7066
}, [wrapperConfig]);
7167

7268
const startMonaco = useCallback(async () => {
73-
if (!wrapperRef.current.isStarting()) {
74-
if (containerRef.current) {
75-
try {
76-
wrapperRef.current.registerTextChangeCallback(onTextChanged);
77-
await wrapperRef.current.start();
78-
onLoad?.(wrapperRef.current);
79-
handleOnTextChanged();
80-
} catch (e) {
81-
if (onError) {
82-
onError(e);
83-
} else {
84-
throw e;
85-
}
69+
if (containerRef.current) {
70+
try {
71+
wrapperRef.current.registerTextChangeCallback(onTextChanged);
72+
await wrapperRef.current.start();
73+
onLoad?.(wrapperRef.current);
74+
handleOnTextChanged();
75+
} catch (e) {
76+
if (onError) {
77+
onError(e);
78+
} else {
79+
throw e;
8680
}
87-
} else {
88-
throw new Error('No htmlContainer found! Aborting...');
8981
}
9082
} else {
91-
await wrapperRef.current.getStartingAwait();
83+
throw new Error('No htmlContainer found! Aborting...');
9284
}
9385
}, [onError, onLoad, onTextChanged]);
9486

@@ -98,11 +90,7 @@ export const MonacoEditorReactComp: React.FC<MonacoEditorProps> = (props) => {
9890

9991
const destroyMonaco = useCallback(async () => {
10092
try {
101-
if (!wrapperRef.current.isStopping()) {
102-
await wrapperRef.current.dispose();
103-
} else {
104-
await wrapperRef.current.getStoppingAwait();
105-
}
93+
await wrapperRef.current.dispose();
10694
} catch {
10795
// The language client may throw an error during disposal.
10896
// This should not prevent us from continue working.

0 commit comments

Comments
 (0)