Created
June 22, 2017 01:08
-
-
Save bendozy/3d9afbc3457eb15de08283fde2a109cf to your computer and use it in GitHub Desktop.
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
import React from 'react'; | |
import Prismic from 'prismic.io'; | |
export default class Pages extends React.Component { | |
state = { | |
doc: null, | |
notFound: false, | |
} | |
componentWillReceiveProps(props) { | |
const api = props.prismicCtx.api; | |
api.form('everything') | |
.ref(api.master()) | |
.query(Prismic.Predicates.at("document.type", "page")) | |
.submit( (err, response) => { | |
if(err) { | |
this.setState({ notFound: true }); | |
return; | |
} | |
const doc = response.results; | |
this.setState({ doc }); | |
}); | |
} | |
render() { | |
if (this.state.doc) { | |
return ( | |
<div className="container"> | |
<h1> Pages content ....</h1> | |
</div> | |
); | |
} else if (this.state.notFound) { | |
return <div> <h2> 404 P Not found </h2></div>; | |
} | |
return <h1>Loading Pages</h1>; | |
} | |
} |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment