profile-details.js 601 B

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