Documents / @faasjs/react / withFaasData
Function: withFaasData()
withFaasData<
PathOrData
,TComponentProps
>(Component
,faasProps
):React.FC
<Omit
<TComponentProps
, keyofFaasDataInjection
<PathOrData
>> &Record
<string
,any
>>
HOC to wrap a component with FaasDataWrapper
Type Parameters
• PathOrData extends FaasAction
• TComponentProps extends Required
<FaasDataInjection
<PathOrData
>> = Required
<FaasDataInjection
<PathOrData
>>
Parameters
• Component: FC
<TComponentProps
& Record
<string
, any
>>
• faasProps: FaasDataWrapperProps
<PathOrData
>
Returns
React.FC
<Omit
<TComponentProps
, keyof FaasDataInjection
<PathOrData
>> & Record
<string
, any
>>
Example
const MyComponent = withFaasData(({ data }) => <div>{data.name}</div>, { action: 'test', params: { a: 1 } })