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.

Async store.getState().intl.locale

See original GitHub issue

I am using react starter kit with redux and intl.

export default {
  path: '/article',
  children: [
    {
      path: '*',
      async action({ path, store }) {
        const language = store.getState().intl.locale;
        await store.dispatch(loadPageData( language,path));
        const data = store.getState().pagedata;
        return { 
          title: data.title,
          component: <Layout><Content content={data} /></Layout>,
        };
      },
    }
  ]
};

The problem is that when i change language using

onClick={async (e) => {
           e.preventDefault();
          await setLocale({ locale });
        }}

first get called SET_LOCALE_START action, then const language = store.getState().intl.locale; then SET_LOCALE_SUCCESS and the result i am using language from previeus state. Any help, suggestion?

Issue Analytics

  • State:closed
  • Created 7 years ago
  • Comments:15

github_iconTop GitHub Comments

1reaction
epozshcommented, Mar 23, 2017

Thanks @langpavel i will make more research and for now i will your 2nd suggested option.

0reactions
langpavelcommented, Mar 22, 2017

@Shadowman4205 Sorry, I cannot guide you to subdomain. It is out of scope and as I said you will have much more configuration with this, not only in RSK but with server configuration as well:

  • You should serve static assets from only one domain
  • This implies CORS setup
  • You must then use domain qualified URL paths for resources
  • Where to put GraphQL endpoint? on common domain? On each domain?
  • Setup redirects to correct domains
  • Check all the cookies, set domain correctly
  • much more questions here… Google/web analytics, SEO, canonical URL

In practice, almost no one using domain prefix because of this. If you think about wikipedia for example, you will see that it is collection of different deployments of same engine with completely different setups.

More common way is to use URL prefix

Read more comments on GitHub >

github_iconTop Results From Across the Web

redux store out of sync store().getState() with state from redux ...
Problem starting when I whant to get current store by store().getState in my App.js. createStore.js const configureStore = preloadedState ...
Read more >
Understanding Asynchronous Redux Actions with Redux Thunk
Learn how to use the Redux Thunk middleware to run asynchronous operations, talk to an API and dispatch actions to the store.
Read more >
Store - Redux
Store. A store holds the whole state tree of your application. The only way to change the state inside it is to dispatch...
Read more >
createAsyncThunk in Redux-Toolkit | by Abhimanyu Chauhan
createAsyncThunk · dispatch: dispatching different actions. · getState: to access the redux store from within the callback · requestId: this is a unique...
Read more >
Building an Awesome Magazine App with i18n in React
It makes sure that our <html> element is synced correctly with our current locale. setLocale also lets our UI i18n library know what...
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