spring-attic / tut-react-and-spring-data-rest

React.js and Spring Data REST :: A tutorial based on the 5-part blog series by Greg Turnquist
https://spring.io/guides/tutorials/react-and-spring-data-rest
882 stars 1.58k forks source link

Can not load employees using new loadFromServer method #11

Closed tur-ing closed 8 years ago

tur-ing commented 8 years ago

In the past (basic) tutorial everything worked fine. Now I have some trouble loading employees using the loadFromServer method.

bildschirmfoto 2016-02-14 um 15 29 18

Line 279 is the var inputs part of UpdateDialog

   render() {
    var inputs = this.props.attributes.map(attribute =>
            <p key={this.props.farmer.entity[attribute]}>
                <input type="text" placeholder={attribute}
                       defaultValue={this.props.farmer.entity[attribute]}
                       ref={attribute} className="field" />
            </p>
);

Accessing /api returns

bildschirmfoto 2016-02-14 um 15 32 42

What might be the problem here?

gregturn commented 8 years ago

What is "props.farmer"? Are you adapting the tutorial to a problem of yours? What changes have you made to do so.

tur-ing commented 8 years ago

In fact:

The app has the following architecture:

problem-spring

I have simply attached a @EnableDiscoveryClient in CbFarmsApplication.java.

Here is the repository cb-farmers (RESTful service): https://github.com/tur-ing/cb-farmers and the repository cb-center: https://github.com/tur-ing/cb-center

tur-ing commented 8 years ago

Please tell me if you need more information. It would be great if you take a look on the running system via Skype (marcel_florian)

tur-ing commented 8 years ago

OK, I removed the whole "Update" functionality - the modal and the methods. Now I can see the table entries again. It seems to be an issue with part on Line 279 I posted before.

gregturn commented 8 years ago

You've made so many changes it might be difficult to eyeball through a few bits. You may want to start sprinkling in some console.log statements, especially where things are breaking.

gregturn commented 8 years ago

It's complaining that "map" is being run against an undefined which hints that this.props.attributes isn't defined. Check if the render() call that creates<UpdateDialog> is passing in something to that particular property correctly. console.log(this.props.attributes) right inside render() might be handy to verify the right data is getting passed into that component.

tur-ing commented 8 years ago

OK, I am going to find out why the this.props.attributes is not set correctly. I am closing this issue for now because it's a bit off-topic compared to the actual tutorial. Thank you Greg!