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

How to Integrate Griddle into existing Redux Store // extraData not passed to customComponent #626

Open
Isarstyle opened this issue Mar 31, 2017 · 11 comments

Comments

@Isarstyle
Copy link

Isarstyle commented Mar 31, 2017

Griddle version 1.2

Expected Behavior

connect(props, dispatch)(Button) on customComponent connects to main App Redux Store

Actual Behavior

i did a connect(props, dispatch)(Button) on a custom component,
but it just connects to the internal griddle redux store, and not to my main Redux store.

Steps to check

the passed store object i get in my custom rows is just the griddle store object, not the main one with the data i need

Do you have a solution for this problem?
Thank You

#621 Is linked to the same problem, i use the redux store to show stateless modals.

EDIT: found out that extra data has been removed from api,
still exists in the Columndefinition... how can i get the extradata back?
//Any extra data that should be passed to each instance of this column
extraData: React.PropTypes.object,

EDIT2:
Found it! in the cellcontainer.js the data is not passed to the customComponent, therefore no access!
<props.customComponent extraData={props.cellProperties.extraData} value={props.value} griddleKey={props.griddleKey} />

@Isarstyle Isarstyle changed the title How to Integrate Griddle into existing Redux Store How to Integrate Griddle into existing Redux Store // extraData not passed to customComponent Apr 1, 2017
@ryanlanciaux
Copy link
Member

This is kind of a bug right now. We are working on making it so Griddle doesn't use "store" as it's store key name for this very reason.

There is a kind of hacky work-around right now that is not a great solution where you can add the app store to context as another name. From there, you can wrap your custom component in a component that gets the app store from the context (keyed by the other name) and passes that in as store prop to your component your connection (there are other ways to with changing store name in connect, etc, as well).

We're trying to make this a nicer experience in the near future. Sorry you're bumping into this!

@Isarstyle
Copy link
Author

maybe there is a way to add the griddle store to the main provider?
example: redux toaster this package is combining it with the reducers, to add a griddle-reducer to my store would be working for me. I just did not want to change the main griddle file, to be compatible to updates :)

I solved it by passing my redux dispatch actions and the store to the extraData, works for me.

@umgupta
Copy link

umgupta commented May 2, 2017

@ryanlanciaux : Any ETA on this, or thoughts on this ? I need griddle states to be maintained in global store. I would really like if I could in some way integrate global store to griddle.

If you have any implementation idea, I can take this up too :)

@dan3721
Copy link

dan3721 commented Jun 12, 2017

  • 1 for ETA?

@dahlbyk
Copy link
Contributor

dahlbyk commented Jun 13, 2017

EDIT: found out that extra data has been removed from api,
still exists in the Columndefinition... how can i get the extradata back?
//Any extra data that should be passed to each instance of this column
extraData: React.PropTypes.object,

EDIT2:
Found it! in the cellcontainer.js the data is not passed to the customComponent, therefore no access!
<props.customComponent extraData={props.cellProperties.extraData} value={props.value} griddleKey={props.griddleKey} />

extraData has been implemented in #675.

@archy-bold
Copy link

Is there a version of Griddle >1.0 that isn't affected by this bug? I really don't like the idea of updating my components to work around this.

@dahlbyk
Copy link
Contributor

dahlbyk commented Jun 13, 2017

Check out #647 for additional discussion related to this issue.

@aftabnaveed
Copy link

aftabnaveed commented Dec 13, 2017

@dahlbyk extraData to the ColumnDefinition seems to be not working, here is my code

<ColumnDefinition id="Actions" customComponent={ActionsColumn} extraData={fetchUsers} />

I am unable to access it my custom component which in this case is ActionsColumn.

@dahlbyk
Copy link
Contributor

dahlbyk commented Dec 13, 2017

@aftabnaveee is fetchUsers a function, perhaps? Keys from extraData are copied into props, so passing a function directly won't do anything.

I expect extraData={{fetchUsers} will expose a fetchUsers prop for you.

@aftabnaveed
Copy link

aftabnaveed commented Dec 13, 2017

fetchUsers is a redux action creator which is passed from my HOC. Here is my custom component

const ActionsColumn = (props) => {
    console.log('extraData', props.extraData); //this logs undefined
    return(
        <div>
            <ViewLinkButton path={url("user/view/"+props.value)} />
            <EditLinkButton path={url("user/edit/"+props.value)} />
            <DeleteButton onClick={() => { console.log('Delete ', props.value) }} />
        </div>
    );
};

@aftabnaveed
Copy link

aftabnaveed commented Dec 13, 2017

Never mind I missed this part

Keys from extraData are copied into props

Thanks.

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

7 participants