Skip to content

Instantly share code, notes, and snippets.


Andrew Gibson AndrewGibson27

View GitHub Profile

ES6 Modules

You can destructure when the export is an object.

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

// index.js
import { foo } from './file1';
AndrewGibson27 /
Last active October 9, 2017 18:26
React and data fetching

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