Skip to content

Commit fea03c8

Browse files
authored
fix: Options should correct the reactEnable flag (#19852)
The reactEnable flag should be automatically corrected to false if vaadin router is used instead of react router.
1 parent c8ff229 commit fea03c8

File tree

2 files changed

+11
-0
lines changed

2 files changed

+11
-0
lines changed

flow-server/src/main/java/com/vaadin/flow/server/frontend/Options.java

Lines changed: 8 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -8,6 +8,8 @@
88
import java.util.Objects;
99
import java.util.Set;
1010

11+
import org.slf4j.LoggerFactory;
12+
1113
import com.vaadin.experimental.FeatureFlags;
1214
import com.vaadin.flow.di.Lookup;
1315
import com.vaadin.flow.server.Constants;
@@ -928,6 +930,12 @@ public boolean isReactEnabled() {
928930

929931
public Options withReact(boolean reactEnable) {
930932
this.reactEnable = reactEnable;
933+
if (reactEnable && !FrontendUtils
934+
.isReactRouterRequired(getFrontendDirectory())) {
935+
LoggerFactory.getLogger(Options.class).debug(
936+
"Setting reactEnable to false as Vaadin Router is used!");
937+
this.reactEnable = false;
938+
}
931939
return this;
932940
}
933941

flow-server/src/test/java/com/vaadin/flow/server/frontend/NodeUpdaterTest.java

Lines changed: 3 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -568,6 +568,9 @@ public void getDefaultDependencies_reactIsUsed_addsHillaReactComponents() {
568568
.mockStatic(FrontendUtils.class)) {
569569
mock.when(() -> FrontendUtils.isHillaUsed(Mockito.any(File.class),
570570
Mockito.any(ClassFinder.class))).thenReturn(true);
571+
mock.when(() -> FrontendUtils
572+
.isReactRouterRequired(Mockito.any(File.class)))
573+
.thenReturn(true);
571574
options.withReact(true);
572575
Map<String, String> defaultDeps = nodeUpdater
573576
.getDefaultDependencies();

0 commit comments

Comments
 (0)