Skip to content

Instantly share code, notes, and snippets.

Avatar

Andrew Gibson AndrewGibson27

  • The Texas Tribune
  • Austin, Texas
View GitHub Profile
View COMBINING_CJS_ES6.md

ES6 Modules

You can destructure when the export is an object.

// file1.js
export { foo, bar };

// index.js
import { foo } from './file1';
View REACT_DATA_FETCHING.md

Data fetching with React

I often find myself puzzling over the best ways to fetch data with React based on whether the app is universal, has Redux, etc. This is an attempt to summarize it all.

Server-side rendering, Redux and React Router 3

Use redial and redux-thunk. The fetch function that decorates the route-handling component should dispatch all data-fetching actions for Redux containers nested in the route. Additional uses of route-specific information (query parameters) can be accessed by sending those props in via mapStateToProps.

Server-side rendering, Redux and React Router 4

From what I can tell, there's no agreed-upon way to do this yet. However, react-router-config is in development to address this scenario. Also, redux-first-router might be helpful. And [Apoll