ga-wdi-exercises/project4

Can't connect redux store

Closed this issue · 3 comments

Hello instructors! Currently, my app is not working at all. Could I get a 10 minute in-person review with one of you in the morning? I think I have everything set up correctly to use Redux to help me manage one state, but I can't figure out how to connect the store to the app to actually begin passing it around.

I found tutorials that use @connect - and I thought I had all of the right plugins installed, but I'm still getting an "unexpected token error" when I try to do that. Then, when I tried to do mapStateToProps and connect that way, state was showing up undefined.

I feel like I'm doing something wrong, but I've confused myself to the point where I don't know which pieces are right and which pieces I should change. Helpppp!

Repo: https://github.com/lizardbird/geopic-frontend

P.S. The gist of what I'm trying to do is: allow user to upload a photo - then add details to that photo upload and send it to my backend - view all photos from backend. It is still working in pieces, I just can't seem to get one state of data to stick with each component.

jsm13 commented

@connect is using a mix-in (proposed future feature of JS) to extend the component. This mixin functionality won't work without preprocessors that create-react-app don't support as far as I know. Instead you want to use the connect function which is a higher order component, a function that takes a component and returns a component. Comparison of the mixin and HOC approaches here.

The function here should return an object and each of the properties on that object will be made available as props.

I've cloned the repo and going to make a PR in a few minutes with a couple changes and notes. I think you're really close here

You're amazing!! Thank you! Will keep an eye out for the PR. I think I am close too! :)

jsm13 commented

PR diff here. So far I just added the redux middleware so it's easier to look at state and then connected the App component passing in the photos array and then using it's length in a heading. Let's move discussion to the PR