Skip to content

Commit

Permalink
fix: Options should correct the reactEnable flag (#19852)
Browse files Browse the repository at this point in the history
The reactEnable flag should be
automatically corrected to
false if vaadin router is used
instead of react router.
  • Loading branch information
caalador committed Aug 30, 2024
1 parent c8ff229 commit fea03c8
Show file tree
Hide file tree
Showing 2 changed files with 11 additions and 0 deletions.
Original file line number Diff line number Diff line change
Expand Up @@ -8,6 +8,8 @@
import java.util.Objects;
import java.util.Set;

import org.slf4j.LoggerFactory;

import com.vaadin.experimental.FeatureFlags;
import com.vaadin.flow.di.Lookup;
import com.vaadin.flow.server.Constants;
Expand Down Expand Up @@ -928,6 +930,12 @@ public boolean isReactEnabled() {

public Options withReact(boolean reactEnable) {
this.reactEnable = reactEnable;
if (reactEnable && !FrontendUtils
.isReactRouterRequired(getFrontendDirectory())) {
LoggerFactory.getLogger(Options.class).debug(
"Setting reactEnable to false as Vaadin Router is used!");
this.reactEnable = false;
}
return this;
}

Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -568,6 +568,9 @@ public void getDefaultDependencies_reactIsUsed_addsHillaReactComponents() {
.mockStatic(FrontendUtils.class)) {
mock.when(() -> FrontendUtils.isHillaUsed(Mockito.any(File.class),
Mockito.any(ClassFinder.class))).thenReturn(true);
mock.when(() -> FrontendUtils
.isReactRouterRequired(Mockito.any(File.class)))
.thenReturn(true);
options.withReact(true);
Map<String, String> defaultDeps = nodeUpdater
.getDefaultDependencies();
Expand Down

0 comments on commit fea03c8

Please sign in to comment.