react-typscript-express-form

form example with react typescript as client, and express as server

Stars
1

react-typscript-express-form

form example with react typescript as client, and express as server

  1. package.json proxyserverfetch('/api/resource')server api
  2. npm library concurrently

  1. https://github.com/Microsoft/TypeScript-React-Starter
  2. https://github.com/piotrwitek/react-redux-typescript-guide#create-store

data fetch (whatwg-fetch)

// fetch example
fetch('/api/hello').then(res => res.json()).then(json => {
  console.log('parsed', json);
}).catch(ex => {
  throw new Error(ex);
});

// async await
async function fetchApi(url: string) {
  const datas = await fetch(url).then(res => res.json());;
}
fetchApi('/api/hello');

use redux-devtools

link: https://github.com/piotrwitek/react-redux-typescript-guide#create-store

declare const window: Window & { devToolsExtension: any,  __REDUX_DEVTOOLS_EXTENSION__: any };
const store = createStore<StoreState>(
  reducers,
  window.__REDUX_DEVTOOLS_EXTENSION__ && window.__REDUX_DEVTOOLS_EXTENSION__() 
);