question-mark
Stuck on an issue?

Lightrun Answers was designed to reduce the constant googling that comes with debugging 3rd party libraries. It collects links to all the places you might be looking at while hunting down a tough bug.

And, if you’re still stuck at the end, we’re happy to hop on a call to see how we can help out.

Accessing the store [Question]

See original GitHub issue

I was trying to access the store that is passed down to html.js from the server.js. First I tried the same approach wih the Connector and passing down the reducer in the connect. But the value for my reducer is always undefined. Is the dispatch part required ? from what I understand I can send connect like this:

const mapStateToProps = ({ tracker }: Reducer) => ({ tracker });

const connector: Connector<{}, Props> = connect(mapStateToProps);

export default connector(FlowHome);

Reducer

/* @flow */

import _ from 'lodash';

import {
  TRACKER_NEXT_STEP,
} from './action';
import type { Tracker, Action } from '../../types';

type State = Tracker;

const initialState = {
  currentStep: '0',
  completedSteps: [],
};

export default (state: State = initialState, action: Action): State => {
  switch (action.type) {
    case TRACKER_NEXT_STEP:
      return _.assign({}, state, { currentStep: action.currentStep });
    default:
      return state;
  }
};

Type

export type Tracker = {
  currentStep: string,
  completedSteps: Array<string>,
}

export type Reducer = {
  tracker: Tracker,
  router: any,
};

export type Action = { type: 'TRACKER_NEXT_STEP', currentStep: string };

Any suggestion on what is the correct way to get the state this way. This reducer specifically is really simple and does not have any calls to the server. And the state holds a string.

Thanks

Issue Analytics

  • State:closed
  • Created 6 years ago
  • Comments:6 (3 by maintainers)

github_iconTop GitHub Comments

1reaction
lgarrocommented, Apr 19, 2017

@wellyshen the problem was the import of the container in routes.js . I was importing the index directly. Thanks

0reactions
wellyshencommented, Apr 19, 2017

@lgarro, Once I have the same question. There’s no a clearly answer, I’d like to recommend you to read the post.

Read more comments on GitHub >

github_iconTop Results From Across the Web

How to access 'store' in react redux? (or how to chain actions)
I've found quote a few questions about it (How to access store in second component in react-redux) but they only talk about accessing...
Read more >
Question: How to access Store from Effect? · Issue #467 - GitHub
I have feature module, with store created by using Store.forFeature and effect initialized by Effect.forFeature .
Read more >
Frequently Asked Questions About Storage
All of our locations have convenient access hours that allow you to access your belongs on your time. Do you have storage options...
Read more >
Solved QUESTION 1 ______ is a back entrance for store
Question : QUESTION 1 ______ is a back entrance for store owners to access, build and configure estore Store Front Admin Console ...
Read more >
Frequently Asked Questions - Epic Games
The Support-A-Creator program enables content Creators to earn money from games in the Epic Games Store by using Creator Links and Creator Tags....
Read more >

github_iconTop Related Medium Post

No results found

github_iconTop Related StackOverflow Question

No results found

github_iconTroubleshoot Live Code

Lightrun enables developers to add logs, metrics and snapshots to live code - no restarts or redeploys required.
Start Free

github_iconTop Related Reddit Thread

No results found

github_iconTop Related Hackernoon Post

No results found

github_iconTop Related Tweet

No results found

github_iconTop Related Dev.to Post

No results found

github_iconTop Related Hashnode Post

No results found