Skip to content

Using async-props with Alt.js #64

@burimshala-zz

Description

@burimshala-zz

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)
);

Metadata

Metadata

Assignees

No one assigned

    Labels

    No labels
    No labels

    Projects

    No projects

    Milestone

    No milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions