Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Using async-props with Alt.js #64

Open
burimshala-zz opened this issue Apr 20, 2016 · 1 comment
Open

Using async-props with Alt.js #64

burimshala-zz opened this issue Apr 20, 2016 · 1 comment

Comments

@burimshala-zz
Copy link

burimshala-zz commented Apr 20, 2016

Since the HoC or AltContainer wraps your component and makes it impossible to call any static method on your component you have to use a util from alt called statics

import connectToStores from 'alt-utils/lib/connectToStores';
import statics from 'alt-utils/lib/statics';

class SomeComponent extends React.Component{
   static getStores() {
        return [SomeStore]
    }

    static getPropsFromStores() {
        return SomeStore.getState()
    }

    render(){
       return ....
    }
}

//declare your functions as constants
const loadProps = (params, cb) => {
  cb(null, {
      tacos: [ 'Pollo', 'Carnitas' ]
    })
}

//pass them to statics first param (used ES6 desctructor)
export default statics(
  { loadAsyncData },
  connectToStores(WorkflowPage)
);
@itsthatguy
Copy link

itsthatguy commented May 19, 2016

Two things:

  1. statics is no longer a thing with current alt.js.
  2. You declare the constant as loadProps but export loadAsyncData

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

No branches or pull requests

2 participants