FaasJS
Home
  • Guide
  • Documents
  • Starter Template
  • Changelog
  • Ecosystem

    • VS Code Plugin
    • Docker Images
  • Github
  • Contributing
  • Sponsor
  • Security
  • English
  • 简体中文
Home
  • Guide
  • Documents
  • Starter Template
  • Changelog
  • Ecosystem

    • VS Code Plugin
    • Docker Images
  • Github
  • Contributing
  • Sponsor
  • Security
  • English
  • 简体中文

Documents / @faasjs/react / withFaasData

Function: withFaasData()

withFaasData<PathOrData, TComponentProps>(Component, faasProps): FC<Omit<TComponentProps, keyof FaasDataInjection<PathOrData>> & Record<string, any>>

HOC to wrap a component with FaasDataWrapper

Type Parameters

PathOrData

PathOrData extends unknown

TComponentProps

TComponentProps extends Required<FaasDataInjection<PathOrData>> = Required<FaasDataInjection<PathOrData>>

Parameters

Component

FC<TComponentProps>

faasProps

FaasDataWrapperProps<PathOrData>

Returns

FC<Omit<TComponentProps, keyof FaasDataInjection<PathOrData>> & Record<string, any>>

Example

const MyComponent = withFaasData(({ data }) => <div>{data.name}</div>, { action: 'test', params: { a: 1 } })