Skip to content

Instantly share code, notes, and snippets.

View juliankrispel's full-sized avatar

Julian Krispel juliankrispel

View GitHub Profile
const express = require('express');
const app = express();
// Application
app.get('/', function(req, res) {
if (process.env.NODE_ENV === 'development') {
for (var key in require.cache) {
delete require.cache[key];
}
}
@markerikson
markerikson / reactiflux-2016-12-12.md
Last active July 29, 2021 18:13
Reactiflux chat: accessing state in thunks

[9:48 PM] jake: Does anyone have a minute to help me think through setting up my actions? I think I'm falling into a rabbit hole of anti patterns.

I'm working on a React Native app. When the user logs in, I want to fetch some initial data from 3 different end points and this data ends up in 3 different (corresponding) reducers. However, the data is related. For example, two of the endpoints are essentially Events and Tags. Tags are accessed through events. So I need to get all events, then once that finishes, I need to iterate through those events and get all tags for each event. I'm not quite sure how to achieve this without accessing the state in my fetchInitialData action.
[9:49 PM] acemarke: so access the state? :)
[9:50 PM] jake: 😃 I stumbled upon this: http://stackoverflow.com/questions/35667249/accessing-redux-state-in-an-action-creator
which emphasizes "Accessing state in action creators is an antipattern and should be avoided when possible" so I was wondering if I'm appr

let BlogPostPage = React.createClass({
render() {
<div>
<SiteNavigation />
<MainContentArea>
{connectToStores({
posts: store => ({
post: store.getPost(this.props.postId),
nextPost: store.getPostAfter(this.props.postId)
})