Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

redux first history #344

Open
wants to merge 9 commits into
base: develop
Choose a base branch
from
Open
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension


Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
6 changes: 4 additions & 2 deletions packages-modules/counter/browser/package.json
Original file line number Diff line number Diff line change
Expand Up @@ -20,7 +20,9 @@
},
"dependencies": {
"@sample-stack/platform-browser": "link:../../../packages/sample-platform/browser",
"antd": "~5.1.7"
"antd": "~5.1.7",
"react-router": "^6.4.0",
"react-router-dom": "^6.4.0"
},
"peerDependencies": {
"@common-stack/client-react": "*",
Expand All @@ -43,4 +45,4 @@
"typescript": {
"definition": "lib/index.d.ts"
}
}
}
Original file line number Diff line number Diff line change
@@ -1,4 +1,4 @@
import * as React from 'react';
import { renderRoutes } from 'react-router-config';
// import { renderRoutes } from 'react-router-config';

export default (props) => <>{renderRoutes(props.route.routes, { matchPath: props.route.path })}</>;
// export default (props) => <>{renderRoutes(props.route.routes, { matchPath: props.route.path })}</>;

This file was deleted.

This file was deleted.

This file was deleted.

This file was deleted.

4 changes: 2 additions & 2 deletions packages-modules/counter/browser/src/index.ts
Original file line number Diff line number Diff line change
Expand Up @@ -2,9 +2,9 @@ import { Feature } from '@common-stack/client-react';

import Common from './common';
import ApolloCounter from './apollo-server-n-client';
import ConnectedReactRouter from './connected-react-router';
import ConnectedReactRouter from './redux-first-history';
import emotion from './emotion';
import { ElectronTrayModule } from './connected-react-router/index.electron';
import { ElectronTrayModule } from './redux-first-history/index.electron';

export default new Feature(Common, ConnectedReactRouter, ApolloCounter, emotion);
export { ElectronTrayModule };
Original file line number Diff line number Diff line change
Expand Up @@ -7,4 +7,4 @@ In Hello link, you will see that the HelloChild component can access router stat

Reference:

https://github.com/supasate/connected-react-router/tree/master/examples/typescript
https://github.com/supasate/redux-first-history/tree/master/examples/typescript
Original file line number Diff line number Diff line change
Expand Up @@ -2,7 +2,7 @@
import * as React from 'react';
import { Dispatch } from 'redux';
import { connect } from 'react-redux';
import { RouteComponentProps } from 'react-router';
// import { RouteComponentProps } from 'react-router';
import { increment, decrement } from '../redux';
import { State } from '../interfaces';

Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -14,9 +14,10 @@ interface HelloChildProps {
const HelloChildComponent = ({ pathname, search, hash }: HelloChildProps) => (
<div>
Hello-Child 23423
<ul>
<li><Link to={`${CONNECTED_REACT_ROUTER_ROUTES_TYPES.HELLO}?color=Blue&size=40`}>with query string</Link></li>
<li><Link to={`${CONNECTED_REACT_ROUTER_ROUTES_TYPES.HELLO}#lovelove`}>with hash</Link></li>
<ul>
{/* <Link>has problem to load. we may not able to use react-router components outside of forntend-server</Link> */}
<li><a href={`${CONNECTED_REACT_ROUTER_ROUTES_TYPES.HELLO}?color=Blue&size=40`}>with query string</a></li>
<li><a href={`${CONNECTED_REACT_ROUTER_ROUTES_TYPES.HELLO}#lovelove`}>with hash</a></li>
</ul>
<div>
pathname: {pathname}
Expand All @@ -31,9 +32,10 @@ const HelloChildComponent = ({ pathname, search, hash }: HelloChildProps) => (
);

const mapStateToProps = (state: State) => ({
pathname: state.router.location.pathname,
search: state.router.location.search,
hash: state.router.location.hash,
pathname: state.router?.location.pathname,
search: state.router?.location.search,
hash: state.router?.location.hash,
});
console.log('---MAP STATE TO PROPS')

export const HelloChild = connect(mapStateToProps)(HelloChildComponent);
Original file line number Diff line number Diff line change
@@ -1,7 +1,7 @@
/* eslint-disable @typescript-eslint/no-unsafe-assignment */
import * as React from 'react';
import { IMenuPosition, IRoute } from '@common-stack/client-react';
import loadable from '@loadable/component'
import loadable from '@loadable/component'


import { getFilteredMenus, getFilteredRoutes } from '../utils';
Expand Down
Original file line number Diff line number Diff line change
@@ -0,0 +1,4 @@
export const enum CONNECTED_REACT_ROUTER_ACTION_TYPES {
INCREMENT = '@redux-first-history/INCREMENT',
DECREMENT = '@redux-first-history/DECREMENT',
}
Original file line number Diff line number Diff line change
@@ -0,0 +1,6 @@
export enum CONNECTED_REACT_ROUTER_ROUTES_TYPES {
ROOT = '/',
HOME = '/redux-first-history',
HELLO = '/redux-first-history/hello',
COUNTER = '/redux-first-history/counter',
}
Original file line number Diff line number Diff line change
@@ -0,0 +1,6 @@
// import { RouterState } from 'redux-first-history';

export interface State {
connectedReactRouterCounter: number;
router?: any;
}
Original file line number Diff line number Diff line change
Expand Up @@ -3,7 +3,7 @@ import { ofType } from 'redux-observable';
import { Observable, of } from 'rxjs';
import { distinctUntilChanged, map, tap, exhaustMap, pluck, catchError, filter } from 'rxjs/operators';
import { ElectronTypes } from '@common-stack/client-core';
import { CONNECTED_REACT_ROUTER_ACTION_TYPES } from '@sample-stack/counter-module-browser/lib/connected-react-router/constants/action-types';
import { CONNECTED_REACT_ROUTER_ACTION_TYPES } from '@sample-stack/counter-module-browser/lib/redux-first-history/constants/action-types';

export const onCountChangedEpic = (
action$: Observable<any>,
Expand Down
2 changes: 1 addition & 1 deletion packages-modules/counter/electron/src/index.ts
Original file line number Diff line number Diff line change
@@ -1,5 +1,5 @@
import { Feature } from '@common-stack/client-react';
import { connectedReactRouterCounter } from '@sample-stack/counter-module-browser/lib/connected-react-router/redux/reducers/counter';
import { connectedReactRouterCounter } from '@sample-stack/counter-module-browser/lib/redux-first-history/redux/reducers/counter';
import { onCountChangedEpic } from './epics';

const ElectronMainModule = new Feature({
Expand Down
Original file line number Diff line number Diff line change
@@ -1,4 +1,4 @@
export const enum CONNECTED_REACT_ROUTER_ACTION_TYPES {
INCREMENT = '@connected-react-router/INCREMENT',
DECREMENT = '@connected-react-router/DECREMENT',
INCREMENT = '@redux-first-server/INCREMENT',
DECREMENT = '@redux-first-server/DECREMENT',
}
Original file line number Diff line number Diff line change
@@ -1,6 +1,6 @@
import { RouterState } from 'connected-react-router';
// import { RouterState } from 'connected-react-router';

export interface State {
connectedReactRouterCounter: number;
router: RouterState;
router: any;
}
5 changes: 0 additions & 5 deletions portable-devices/browser-extension/package.json
Original file line number Diff line number Diff line change
Expand Up @@ -54,15 +54,13 @@
"body-parser": "^1.18.2",
"browser-bunyan": "^1.6.3",
"classnames": "^2.2.6",
"connected-react-router": "^6.9.1",
"cors": "^2.8.5",
"dotenv": "^8.2.0",
"envalid": "~7.2.2",
"esm": "^3.2.25",
"flat": "^4.0.0",
"graphql-tag": "^2.11.0",
"graphql-ws": "^5.11.2",
"history": "^4.10.1",
"immutability-helper": "^3.0.1",
"inversify": "^6.0.2",
"isomorphic-fetch": "^2.2.1",
Expand All @@ -78,9 +76,6 @@
"react-loadable": "^5.5.0",
"react-redux": "^7.1.3",
"react-resizable": "^1.10.1",
"react-router": "^5.3.3",
"react-router-config": "^5.1.1",
"react-router-dom": "^5.1.2",
"react-transition-group": "^4.3.0",
"redux": "^4.0.5",
"redux-logger": "^3.0.6",
Expand Down
8 changes: 3 additions & 5 deletions portable-devices/desktop/package.json
Original file line number Diff line number Diff line change
Expand Up @@ -58,7 +58,6 @@
"apollo-server-errors": "^3.3.1",
"check-internet-connected": "^2.0.5",
"classnames": "^2.2.6",
"connected-react-router": "^6.9.1",
"cors": "^2.8.5",
"cross-env": "^7.0.3",
"dotenv": "^8.2.0",
Expand All @@ -71,7 +70,6 @@
"graphql": "^15.0.0",
"graphql-tag": "^2.11.0",
"graphql-ws": "^5.11.2",
"history": "^4.10.1",
"immutability-helper": "^3.0.1",
"inversify": "^6.0.2",
"inversify-binding-decorators": "^4.0.0",
Expand All @@ -86,9 +84,6 @@
"react-helmet": "^6.1.0",
"react-loadable": "^5.5.0",
"react-redux": "^7.1.3",
"react-router": "^5.3.3",
"react-router-config": "^5.1.1",
"react-router-dom": "^5.3.3",
"react-transition-group": "^4.3.0",
"redux": "^4.0.5",
"redux-logger": "^3.0.6",
Expand Down Expand Up @@ -119,6 +114,9 @@
"rimraf": "^3.0.2",
"workspaces-utils": "^1.2.1"
},
"peerDependencies": {
"connected-react-router": "^6.9.3"
},
"buildAbout": {
"appName": "Fullstack-Pro",
"apiApp": "https://time-tracker-api.herokuapp.com/"
Expand Down
6 changes: 3 additions & 3 deletions portable-devices/desktop/src/renderer/app/Tray.tsx
Original file line number Diff line number Diff line change
Expand Up @@ -3,7 +3,7 @@ import { ApolloProvider } from '@apollo/client';
import { Provider } from 'react-redux';
import { createClientContainer } from '../config/main/client.service';
import { epic$ } from '../config/tray/epic-config';
import { ConnectedRouter } from 'connected-react-router';
import { HistoryRouter } from 'redux-first-history/rr6';
import { createReduxStore, history } from '../config/tray/redux-config';
import { MainRoute } from '../modules/tray';
import { ErrorBoundary } from './ErrorBoundary';
Expand Down Expand Up @@ -44,9 +44,9 @@ export class Main extends React.Component<{}, {}> {
<ErrorBoundary>
<Provider store={store}>
<ApolloProvider client={client}>
<ConnectedRouter history={history}>
<HistoryRouter history={history}>
<MainRoute />
</ConnectedRouter>,
</HistoryRouter>,
</ApolloProvider>
</Provider>
</ErrorBoundary>
Expand Down
6 changes: 0 additions & 6 deletions portable-devices/mobile/package.json
Original file line number Diff line number Diff line change
Expand Up @@ -83,7 +83,6 @@
"apollo-link-logger": "^2.0.0",
"apollo-server-errors": "^3.3.1",
"big-integer": "^1.6.51",
"connected-react-router": "^6.9.1",
"expo": "~48.0.20",
"expo-asset": "~8.9.1",
"expo-build-properties": "~0.6.0",
Expand All @@ -102,7 +101,6 @@
"expo-updates": "~0.16.4",
"expo-web-browser": "~12.1.1",
"graphql-ws": "^5.11.2",
"history": "^4.10.1",
"immutability-helper": "^3.0.1",
"inversify": "^6.0.2",
"isomorphic-fetch": "^2.2.1",
Expand Down Expand Up @@ -131,10 +129,6 @@
"react-native-web": "~0.18.10",
"react-native-web-maps": "~0.3.0",
"react-redux": "^7.1.3",
"react-router": "^5.3.3",
"react-router-config": "^5.1.1",
"react-router-dom": "^5.3.3",
"react-router-native": "^5.3.3",
"redux": "^4.0.5",
"redux-logger": "^3.0.6",
"redux-observable": "^1.2.0",
Expand Down
3 changes: 0 additions & 3 deletions portable-devices/mobile/src/App.tsx
Original file line number Diff line number Diff line change
Expand Up @@ -7,7 +7,6 @@ import { Provider } from 'react-redux';
import { MainRoute } from './modules/modules';
import { persistStore } from 'redux-persist';
import { PersistGate } from 'redux-persist/integration/react';
import { ConnectedRouter } from 'connected-react-router';
import {
createReduxStore,
history,
Expand All @@ -29,9 +28,7 @@ export default function App() {
<ApolloProvider client={client}>
<PersistGate persistor={persistor}>
<NativeRouter>
<ConnectedRouter history={history}>
<MainRoute />
</ConnectedRouter>
</NativeRouter>
</PersistGate>
</ApolloProvider>
Expand Down
9 changes: 4 additions & 5 deletions servers/frontend-server/package.json
Original file line number Diff line number Diff line change
Expand Up @@ -71,7 +71,6 @@
"apollo-server-errors": "^3.3.1",
"classnames": "^2.2.6",
"compression": "^1.7.4",
"connected-react-router": "^6.9.1",
"cors": "^2.8.5",
"dotenv": "^8.2.0",
"envalid": "~7.2.2",
Expand All @@ -81,7 +80,7 @@
"graphql": "^15.0.0",
"graphql-tag": "^2.11.0",
"graphql-ws": "^5.11.2",
"history": "^4.10.1",
"history": "^5.0.0",
"immutability-helper": "^3.0.1",
"inversify": "^6.0.2",
"ioredis": "^4.14.0",
Expand All @@ -96,12 +95,12 @@
"react-helmet-async": "^1.3.0",
"react-loadable": "^5.5.0",
"react-redux": "^7.1.3",
"react-router": "^5.3.3",
"react-router-config": "^5.1.1",
"react-router-dom": "^5.3.3",
"react-router": "^6.4.0",
"react-router-dom": "^6.4.0",
"react-transition-group": "^4.3.0",
"redis": "^2.8.0",
"redux": "^4.0.5",
"redux-first-history": "^5.1.1",
"redux-logger": "^3.0.6",
"redux-observable": "^1.2.0",
"redux-persist": "^6.0.0",
Expand Down
Loading