File tree 3 files changed +30
-4
lines changed
3 files changed +30
-4
lines changed Original file line number Diff line number Diff line change 1
1
import React from 'react'
2
- import UserWidget from './UserWidget'
2
+ import UserWidgetComp from './UserWidgetComp'
3
+ import UserWidgetFunc from './UserWidgetFunc'
3
4
4
5
interface Props {
5
6
userId : string ,
@@ -9,7 +10,8 @@ export default class UserPage extends React.Component<Props> {
9
10
render ( ) {
10
11
return (
11
12
< div >
12
- < UserWidget userId = { this . props . userId } />
13
+ < UserWidgetComp userId = { this . props . userId } />
14
+ < UserWidgetFunc userId = { this . props . userId } />
13
15
</ div >
14
16
)
15
17
}
Original file line number Diff line number Diff line change @@ -10,7 +10,7 @@ interface InnerProps extends OuterProps {
10
10
userFetch : PromiseState < User >
11
11
}
12
12
13
- class UserWidget extends React . Component < InnerProps > {
13
+ class UserWidgetComp extends React . Component < InnerProps > {
14
14
render ( ) {
15
15
return (
16
16
< ul >
@@ -23,4 +23,4 @@ class UserWidget extends React.Component<InnerProps> {
23
23
24
24
export default connect < OuterProps , InnerProps > ( ( props ) => ( {
25
25
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