mirror of
				https://github.com/aleleba/create-react-ssr.git
				synced 2025-10-30 21:51:01 -06:00 
			
		
		
		
	PR-589725: Updating packages, fixing redux actions and fixing linting.
This commit is contained in:
		
							
								
								
									
										4
									
								
								src/@types/express/index.d.ts
									
									
									
									
										vendored
									
									
								
							
							
						
						
									
										4
									
								
								src/@types/express/index.d.ts
									
									
									
									
										vendored
									
									
								
							| @@ -1,4 +1,4 @@ | ||||
| import * as express from "express" | ||||
| import * as express from 'express'; | ||||
|  | ||||
| declare global { | ||||
| 	namespace Express { | ||||
| @@ -6,4 +6,4 @@ declare global { | ||||
| 		hashManifest?: Record<string,any> | ||||
| 	  } | ||||
| 	} | ||||
| } | ||||
| } | ||||
|   | ||||
							
								
								
									
										2
									
								
								src/@types/index.d.ts
									
									
									
									
										vendored
									
									
								
							
							
						
						
									
										2
									
								
								src/@types/index.d.ts
									
									
									
									
										vendored
									
									
								
							| @@ -1,4 +1,4 @@ | ||||
| declare module "*.svg" { | ||||
| declare module '*.svg' { | ||||
|     const content: any; | ||||
|     export default content; | ||||
| } | ||||
|   | ||||
| @@ -6,22 +6,22 @@ import initialStateReducer from '../frontend/reducers/initialState'; | ||||
| import setStore from '../frontend/setStore'; | ||||
|  | ||||
| export const ProviderMock = ({ children, initialState }: { children: any, initialState?: any}) => { | ||||
|     let initialStateMock = initialStateReducer | ||||
| 	let initialStateMock = initialStateReducer; | ||||
|  | ||||
|     if(initialState !== undefined){ | ||||
|         initialStateMock = initialState | ||||
|     } | ||||
| 	if(initialState !== undefined){ | ||||
| 		initialStateMock = initialState; | ||||
| 	} | ||||
|  | ||||
|     const history = createMemoryHistory(); | ||||
|     const store = setStore({ initialState: initialStateMock }); | ||||
| 	const history = createMemoryHistory(); | ||||
| 	const store = setStore({ initialState: initialStateMock }); | ||||
|  | ||||
|     return( | ||||
|         <Provider store={store}> | ||||
|             <Router location={history.location} navigator={history}> | ||||
|                 {children} | ||||
|             </Router> | ||||
|         </Provider> | ||||
|     ) | ||||
| } | ||||
| 	return( | ||||
| 		<Provider store={store}> | ||||
| 			<Router location={history.location} navigator={history}> | ||||
| 				{children} | ||||
| 			</Router> | ||||
| 		</Provider> | ||||
| 	); | ||||
| }; | ||||
|  | ||||
| export default ProviderMock; | ||||
|   | ||||
| @@ -1,9 +1 @@ | ||||
| import test, { TTest } from './testAction'; | ||||
|  | ||||
| export type TAction = TTest  | ||||
|  | ||||
| const actions = { | ||||
|     test | ||||
| } | ||||
|  | ||||
| export default actions | ||||
| export * from '@actions/testAction'; | ||||
|   | ||||
| @@ -14,12 +14,12 @@ export interface IChangeHelloPayload { | ||||
| export type TTest = IChangeHello | ||||
|  | ||||
| const changeHello = (payload: string) => ({ | ||||
|     type: ActionTypesTest.ChangeHello, | ||||
|     payload | ||||
| }) | ||||
| 	type: ActionTypesTest.ChangeHello, | ||||
| 	payload | ||||
| }); | ||||
|  | ||||
| const actions = { | ||||
|     changeHello | ||||
| } | ||||
| 	changeHello | ||||
| }; | ||||
|  | ||||
| export default actions | ||||
| export default actions; | ||||
|   | ||||
| @@ -1,18 +1,18 @@ | ||||
| import React from 'react'; | ||||
| import logo from '../logo.svg'; | ||||
| import './InitialComponent.scss'; | ||||
| import { Link } from "react-router-dom"; | ||||
| import { Link } from 'react-router-dom'; | ||||
|  | ||||
| const OtherComponent = () => ( | ||||
|     <div className="App"> | ||||
|       <header className="App-header"> | ||||
|         <img src="assets/img/logo.svg" className="App-logo" alt="logo" /> | ||||
|         <p> | ||||
| 	<div className="App"> | ||||
| 		<header className="App-header"> | ||||
| 			<img src="assets/img/logo.svg" className="App-logo" alt="logo" /> | ||||
| 			<p> | ||||
|             Edit <code>src/frontend/OtherComponent.jsx</code> and save to reload. | ||||
|         </p> | ||||
|         <Link className="App-link" to="/">Initial Component</Link> | ||||
|       </header> | ||||
|     </div> | ||||
| 			</p> | ||||
| 			<Link className="App-link" to="/">Initial Component</Link> | ||||
| 		</header> | ||||
| 	</div> | ||||
| ); | ||||
|  | ||||
| export default OtherComponent; | ||||
|   | ||||
| @@ -4,7 +4,7 @@ import { useRoutes } from 'react-router-dom'; | ||||
| import routes from '../../routes'; | ||||
|  | ||||
| const PrincipalRoutes = () => { | ||||
| 	let element = useRoutes(routes); | ||||
| 	const element = useRoutes(routes); | ||||
| 	return element; | ||||
| }; | ||||
|  | ||||
|   | ||||
| @@ -4,20 +4,20 @@ import { ProviderMock } from '@mocks'; | ||||
| import App from '@components/App'; | ||||
|  | ||||
| describe('<App/> Component', () => { | ||||
|     beforeEach(() => { | ||||
|         fetchMock.resetMocks(); | ||||
|     }); | ||||
| 	beforeEach(() => { | ||||
| 		fetchMock.resetMocks(); | ||||
| 	}); | ||||
|  | ||||
|     it('Should render root <App /> Component', async () => { | ||||
|         fetchMock.mockResponseOnce(JSON.stringify({ | ||||
|             //First Data Fetch | ||||
|             data: 'data' | ||||
|         })); | ||||
| 	it('Should render root <App /> Component', async () => { | ||||
| 		fetchMock.mockResponseOnce(JSON.stringify({ | ||||
| 			//First Data Fetch | ||||
| 			data: 'data' | ||||
| 		})); | ||||
|  | ||||
|         render( | ||||
|             <ProviderMock> | ||||
|                 <App /> | ||||
|             </ProviderMock> | ||||
|         ) | ||||
|     }) | ||||
| }) | ||||
| 		render( | ||||
| 			<ProviderMock> | ||||
| 				<App /> | ||||
| 			</ProviderMock> | ||||
| 		); | ||||
| 	}); | ||||
| }); | ||||
|   | ||||
| @@ -1,10 +1,6 @@ | ||||
| import { combineReducers } from 'redux'; | ||||
| import testReducer from './testReducer'; | ||||
| import { IChangeHelloPayload } from '../actions/testAction'; | ||||
|  | ||||
| export interface IInitialState { | ||||
| 	testReducer?: IChangeHelloPayload | undefined | ||||
| } | ||||
| export * from './initialState'; | ||||
|  | ||||
| const rootReducer = combineReducers({ | ||||
| 	// Here comes the reducers | ||||
|   | ||||
| @@ -1,3 +1,6 @@ | ||||
| import { IInitialState } from './'; | ||||
| import { IChangeHelloPayload } from '@actions'; | ||||
| export interface IInitialState { | ||||
| 	testReducer?: IChangeHelloPayload | undefined | ||||
| } | ||||
| const initialState: IInitialState = {}; | ||||
| export default  initialState; | ||||
|   | ||||
| @@ -1,10 +1,10 @@ | ||||
| import { TAction } from '../actions'; | ||||
| import { TTest } from '@actions'; | ||||
|  | ||||
| const initialState = { | ||||
| 	hello: 'world' | ||||
| }; | ||||
|  | ||||
| const testReducer = (state = initialState, action: TAction) => { | ||||
| const testReducer = (state = initialState, action: TTest) => { | ||||
| 	switch (action.type){ | ||||
| 	case 'CHANGE_HELLO': { | ||||
| 		const newHello = action.payload.hello; | ||||
|   | ||||
| @@ -3,8 +3,7 @@ import { legacy_createStore as createStore} from 'redux'; //, applyMiddleware | ||||
| // import { Provider } from 'react-redux'; | ||||
| import { composeWithDevTools as composeWithDevToolsWeb } from '@redux-devtools/extension'; | ||||
| import { config } from '../../config'; | ||||
| import reducer, { IInitialState } from './reducers'; | ||||
|  | ||||
| import reducer, { IInitialState } from '@reducers'; | ||||
|  | ||||
| const { ENV } = config; | ||||
|  | ||||
| @@ -15,11 +14,11 @@ const composeEnhancers = composeWithDevToolsWeb({ | ||||
| const setStore = ({ initialState }: { initialState: IInitialState | undefined }) => { | ||||
| 	const store = ENV === 'development' ? createStore( | ||||
| 		reducer, | ||||
| 		initialState, | ||||
| 		initialState as any, | ||||
| 		composeEnhancers(), | ||||
| 	) : createStore( | ||||
| 		reducer, | ||||
| 		initialState, | ||||
| 		initialState as any, | ||||
| 	); | ||||
| 	return store; | ||||
| }; | ||||
|   | ||||
| @@ -129,7 +129,7 @@ const renderApp = (req, res, next) => { | ||||
| }; | ||||
|  | ||||
| app | ||||
| 	.get('*', renderApp); | ||||
| 	.get(/\*/, renderApp); | ||||
|  | ||||
| app.listen(PORT, () => { | ||||
| 	console.log(`Server running on port ${PORT}`); | ||||
|   | ||||
		Reference in New Issue
	
	Block a user