ParseReact icon indicating copy to clipboard operation
ParseReact copied to clipboard

new Parse.Query doesn't work in ParseComponent (for ES6)

Open jbbae opened this issue 8 years ago • 11 comments

The updates for ParseComponent for ES6-based code states that all of the same methods in the ParseReact.Mixin should work the same way. However, the "new Parse.Query" doesn't seem to grab anything...? listItems seems always to be empty.

Notes: a) I have verified the connection with Parse (using the "TestObject" code provided in the QuickStart section in Parse.com)

Thanks so much in advance! I'm new to web dev, and just happened to start with React & Parse, so please excuse if this is a silly mistake. (Below is the shortened code based on feedback below)

import React from 'react';
import Parse from 'parse';
import ParseReact from 'parse-react';
let ParseComponent = ParseReact.Component(React);

export default class ExplorerWithNav extends ParseComponent {

observe() {
  return {
    listItems: (new Parse.Query('Focus')).ascending('name')
  };
}

render() {
  let listitems;
  let itemDescription;

  if (this.data.listItems.length) {
    listitems = (
      <List subheader="Your Options">
      {this.data.listItems.map(function(item, i) {
        return (
          <ListItem
            key={i}
            primaryText={item.name} />
        );
      }, this)}
      </List>
    );
  }

  if (this.state.selecteditem.length > 0) {
    itemDescription = <p>Hi!</p>;
  }

  return (
    <div>
      <div>
        {itemDescription}
      </div>
      <div>
        {listitems}
      </div>
    </div>
  );
}
}

jbbae avatar Dec 04 '15 09:12 jbbae