Skip to content
Snippets Groups Projects
Commit f2022384 authored by john's avatar john
Browse files

add willreceiveprops to handle async call to get fragments

parent b1184a9d
No related branches found
No related tags found
No related merge requests found
...@@ -32,6 +32,8 @@ export class BookBuilder extends React.Component { ...@@ -32,6 +32,8 @@ export class BookBuilder extends React.Component {
const { actions, book } = this.props const { actions, book } = this.props
const { getCollections, getFragments, getTeams, getUsers } = actions const { getCollections, getFragments, getTeams, getUsers } = actions
console.log('props', this.props)
getUsers().then( getUsers().then(
() => getTeams() () => getTeams()
).then( ).then(
...@@ -41,23 +43,24 @@ export class BookBuilder extends React.Component { ...@@ -41,23 +43,24 @@ export class BookBuilder extends React.Component {
} }
).then( ).then(
() => { () => {
console.log(book.id) if (book.id) {
if (book.id) getFragments(book) console.log('has book id')
getFragments(book)
}
} }
) )
} }
// componentWillReceiveProps (nextProps) { componentWillReceiveProps (nextProps) {
// const { actions, book } = nextProps console.log('next', nextProps)
// const { getFragments } = actions const { actions, book } = nextProps
// // const { getFragments } = actions
// console.log(book)
// console.log(this.props) if (book.id && book.id !== this.props.book.id) {
// // console.log('here')
// // if (book.id && book.id !== this.props.id) { getFragments(book)
// // // getFragments(book) }
// // } }
// }
componentDidMount () { componentDidMount () {
// I'm using the ref inside the render function it was created in // I'm using the ref inside the render function it was created in
...@@ -252,12 +255,12 @@ BookBuilder.propTypes = { ...@@ -252,12 +255,12 @@ BookBuilder.propTypes = {
} }
function mapStateToProps (state, ownProps) { function mapStateToProps (state, ownProps) {
console.log(state)
let book = _.find(state.collections, function (c) { let book = _.find(state.collections, function (c) {
return c.id === ownProps.params.id return c.id === ownProps.params.id
}) })
console.log(state)
let chapters = _.sortBy(_.filter(state.fragments, function (f) { let chapters = _.sortBy(_.filter(state.fragments, function (f) {
return f.book === book.id && f.id && !f.deleted return f.book === book.id && f.id && !f.deleted
}), 'index') }), 'index')
......
0% or .
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment