Advertisement
Guest User

Untitled

a guest
Apr 18th, 2019
95
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
text 0.87 KB | None | 0 0
  1. import React from 'react';
  2. import { connect } from 'react-redux';
  3. import State from '@state';
  4. import { sendGetRequest } from '~/redux/systemActions/common';
  5.  
  6. interface IDefaultProps {
  7. title: string;
  8. test: string;
  9. }
  10.  
  11. interface IProps extends Partial<IDefaultProps> {
  12. users: any;
  13. }
  14.  
  15. class ClassWithDispatch extends React.PureComponent<IProps> {
  16. static defaultProps: IDefaultProps = {
  17. title: 'title',
  18. test: '123',
  19. };
  20.  
  21. constructor(props: IProps) {
  22. super(props);
  23. }
  24.  
  25. componentDidMount(): void {
  26. const { dispatch } = this.props;
  27. dispatch(sendGetRequest({
  28. url: '/test/api/url',
  29. data: [],
  30. }));
  31. }
  32.  
  33. render() {
  34. const { users } = this.props;
  35.  
  36. return (
  37. <div>
  38. Temp file
  39. </div>
  40. );
  41. }
  42. }
  43.  
  44. const mapStateToProps = (state: State) => ({
  45. users: state.users,
  46. });
  47.  
  48. export default connect(mapStateToProps)(ClassWithDispatch);
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement