( modelName: string, mapState?: Function | undefined, mapActions?: Function | undefined )
| 404 | } |
| 405 | |
| 406 | const connect = ( |
| 407 | modelName: string, |
| 408 | mapState?: Function | undefined, |
| 409 | mapActions?: Function | undefined |
| 410 | ) => (Component: typeof React.Component | typeof PureComponent) => |
| 411 | class P extends PureComponent<any> { |
| 412 | render() { |
| 413 | const { state: prevState = {}, actions: prevActions = {} } = this.props |
| 414 | return ( |
| 415 | <Consumer> |
| 416 | {(models) => { |
| 417 | const { [`${modelName}`]: state } = models as any |
| 418 | const actions = Global.Actions[modelName] |
| 419 | return ( |
| 420 | <Component |
| 421 | {...this.props} |
| 422 | state={{ |
| 423 | ...prevState, |
| 424 | ...(mapState ? mapState(state) : state) |
| 425 | }} |
| 426 | actions={{ |
| 427 | ...prevActions, |
| 428 | ...(mapActions |
| 429 | ? mapActions(consumerActions(actions, { modelName })) |
| 430 | : consumerActions(actions, { modelName })) |
| 431 | }} |
| 432 | /> |
| 433 | ) |
| 434 | }} |
| 435 | </Consumer> |
| 436 | ) |
| 437 | } |
| 438 | } |
| 439 | |
| 440 | export { |
| 441 | actionMiddlewares, |
no outgoing calls
no test coverage detected
searching dependent graphs…