profile-details.js 563 B

123456789101112131415161718192021222324
  1. import React from "react"
  2. import { load } from "misago/reducers/profile-details"
  3. import ajax from "misago/services/ajax"
  4. import snackbar from "misago/services/snackbar"
  5. export default class extends React.Component {
  6. componentDidMount() {
  7. const { data, dispatch, user } = this.props
  8. if (data && data.id === user.id) return
  9. ajax.get(this.props.user.api.details).then(
  10. data => {
  11. dispatch(load(data))
  12. },
  13. rejection => {
  14. snackbar.apiError(rejection)
  15. }
  16. )
  17. }
  18. render() {
  19. return this.props.children
  20. }
  21. }