File tree Expand file tree Collapse file tree
Expand file tree Collapse file tree Original file line number Diff line number Diff line change 11import React from 'react'
2- import UserWidget from './UserWidget'
2+ import UserWidgetComp from './UserWidgetComp'
3+ import UserWidgetFunc from './UserWidgetFunc'
34
45interface Props {
56 userId : string ,
@@ -9,7 +10,8 @@ export default class UserPage extends React.Component<Props> {
910 render ( ) {
1011 return (
1112 < div >
12- < UserWidget userId = { this . props . userId } />
13+ < UserWidgetComp userId = { this . props . userId } />
14+ < UserWidgetFunc userId = { this . props . userId } />
1315 </ div >
1416 )
1517 }
Original file line number Diff line number Diff line change @@ -10,7 +10,7 @@ interface InnerProps extends OuterProps {
1010 userFetch : PromiseState < User >
1111}
1212
13- class UserWidget extends React . Component < InnerProps > {
13+ class UserWidgetComp extends React . Component < InnerProps > {
1414 render ( ) {
1515 return (
1616 < ul >
@@ -23,4 +23,4 @@ class UserWidget extends React.Component<InnerProps> {
2323
2424export default connect < OuterProps , InnerProps > ( ( props ) => ( {
2525 userFetch : `/users/${ props . userId } `
26- } ) ) ( UserWidget )
26+ } ) ) ( UserWidgetComp )
Original file line number Diff line number Diff line change 1+ import React from 'react'
2+ import { connect , PromiseState } from '../../src'
3+ import { User } from './types'
4+
5+ interface OuterProps {
6+ userId : string
7+ }
8+
9+ interface InnerProps extends OuterProps {
10+ userFetch : PromiseState < User >
11+ }
12+
13+ function UserWidgetFunc ( props : InnerProps ) {
14+ return (
15+ < ul >
16+ < li > { props . userId } </ li >
17+ < li > { props . userFetch . fulfilled && props . userFetch . value . name } </ li >
18+ </ ul >
19+ )
20+ }
21+
22+ export default connect < OuterProps , InnerProps > ( ( props ) => ( {
23+ userFetch : `/users/${ props . userId } `
24+ } ) ) ( UserWidgetFunc )
You can’t perform that action at this time.
0 commit comments