Skip to content

Commit 8274de0

Browse files
authored
Fix vue config and add view for react app (#161)
1 parent 82d6860 commit 8274de0

File tree

3 files changed

+18
-18
lines changed

3 files changed

+18
-18
lines changed

packages/devextreme-cli/templates/react/application/src/app-routes.js

Lines changed: 1 addition & 15 deletions
Original file line numberDiff line numberDiff line change
@@ -1,5 +1,4 @@
1-
import React, { useEffect } from 'react';
2-
import { useNavigation } from './contexts/navigation';
1+
import { withNavigationWatcher } from './contexts/navigation';
32
<%=^empty%>import { HomePage, DisplayDataPage, ProfilePage } from './pages';
43

54
<%=/empty%>const routes = [<%=^empty%>
@@ -23,16 +22,3 @@ export default routes.map(route => {
2322
component: withNavigationWatcher(route.component)
2423
};
2524
});
26-
27-
function withNavigationWatcher(Component) {
28-
return function (props) {
29-
const { path } = props.match;
30-
const { setNavigationData } = useNavigation();
31-
32-
useEffect(() => {
33-
setNavigationData({ currentPath: path });
34-
}, [path, setNavigationData]);
35-
36-
return React.createElement(Component, props);
37-
}
38-
}

packages/devextreme-cli/templates/react/application/src/contexts/navigation.js

Lines changed: 16 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -1,4 +1,4 @@
1-
import React, { useState, createContext, useContext } from 'react';
1+
import React, { useState, createContext, useContext, useEffect } from 'react';
22

33
const NavigationContext = createContext({});
44
const useNavigation = () => useContext(NavigationContext);
@@ -14,7 +14,21 @@ function NavigationProvider(props) {
1414
);
1515
}
1616

17+
function withNavigationWatcher(Component) {
18+
return function (props) {
19+
const { path } = props.match;
20+
const { setNavigationData } = useNavigation();
21+
22+
useEffect(() => {
23+
setNavigationData({ currentPath: path });
24+
}, [path, setNavigationData]);
25+
26+
return React.createElement(Component, props);
27+
}
28+
}
29+
1730
export {
1831
NavigationProvider,
19-
useNavigation
32+
useNavigation,
33+
withNavigationWatcher
2034
}
Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1,3 +1,3 @@
11
module.exports = {
2-
publicPath: "devextreme-vue-template"
2+
publicPath: "/devextreme-vue-template"
33
};

0 commit comments

Comments
 (0)