Does Apollo client have some sort of thing like mapStateToProps
(Redux)?
let's say I have a component, after query I know there's data in the cache so I do something like:
class Container extends React.Component {
...
...
render() {
const notes = this.props.client.readFragment(NOTES_FRAGMENT)
// notes has everything I need
return (<Child notes={notes} />);
}
}
export default WithApollo(Container);
However when I have a sibling component which calls mutation and do update, the <Child />
component's props never get updates.
class AnotherContainer extends React.Component {
render() {
return(
<Mutation
mutation={UPDATE_NOTE}
update={(cache, {data: {updateNote}}) =? {
const list = cache.readFragment({
fragment: NOTES_FRAGMENT
})
// manipulate list
cache.writeFragment({fragment:NOTES_FRAGMENT, data })
}
}
)
}
}
so my question is, how do I update the <Child />
component's props whenever I do writeFragment? is there anything like mapStateToProps thing to "connect" the notes
props to the cache, so whenever it updates, will trigger the React lifecycle?