Not sure what I am doing wrong but I receiving the following error message after I click on the submit button:
TypeError: this.props.ObjectQuery is not a function
The code for query is as follows:
const ObjectQuery = gql`
query($timestamp: Float!){
action(timestamp: $timestamp){
action
timestamp
object{
filename
}
}
}
`;
class UserList extends React.Component {
render() {
return (
({ loading, error, data }) => {
if (loading) return <p>Loading...</p>;
if (error) {
console.log(error);
return <p>Error</p>;
}
if (data.action.length === 0) return <div>No Objects</div>;
return (//this code binds the query above to the output and puts it on the screen.
<Item.Group divided>
{data.action.map(action => (
<div>
<ul>
<li key = {action.action}>{action.action}</li>
<li key = {action.timestamp}>{action.timestamp}</li>
<ul>
{action.object.map((obj) => {
return (<li>{obj.filename}</li>)
})}
</ul>
</ul>
</div>
))}
</Item.Group>
);
}
)};
}
export default graphql(ObjectQuery, {
options: (props) => ({variables: {timestamp: props.timestamp}})
})(UserList);
This is the code for the submit button. Also, for some reason the import statement is grayed out.
import ObjectQuery from '../UserList';
handleSubmit(event) {
event.preventDefault();
console.log(this.state)
this.setState({ inputValue: new Date(document.getElementById("time").value ).valueOf() });
this.props.ObjectQuery({
variables:{
timestamp: this.state.inputValue
},
});
}