I am using office-ui-fabric card in my spfx web part. Getting the error as below.

    createComponent.tsx:51 Uncaught TypeError: external__react_.useContext is not a function
    at result (createComponent.tsx:51)
    at mountIndeterminateComponent (react-dom.development.js:14938)
    at beginWork (react-dom.development.js:15443)
    at performUnitOfWork (react-dom.development.js:18277)
    at workLoop (react-dom.development.js:18317)
    at HTMLUnknownElement.callCallback (react-dom.development.js:143)
    at Object.invokeGuardedCallbackDev (react-dom.development.js:193)
    at invokeGuardedCallback (react-dom.development.js:250)
    at replayUnitOfWork (react-dom.development.js:17564)
    at renderRoot (react-dom.development.js:18436)

backend.js:6 The above error occurred in the <Stack> component:
    in Stack (created by RealtimeData)
    in div (created by RealtimeData)
    in RealtimeData (created by Stock)
    in div (created by Stock)
    in div (created by Stock)
    in Stock


return (

                 <Stack tokens={sectionStackTokens}>
                    <Card horizontal tokens={cardTokens}>
                        <Text>Basic horizontal card</Text>

                    <Card horizontal onClick={alertClicked} tokens={cardTokens}>
                    <Card.Item fill>
                        <Image src="https://placehold.it/180x135" alt="Placeholder image." />
                        <Text variant="small" styles={siteTextStyles}>
                        <Text styles={descriptionTextStyles}>Contoso Denver expansion design marketing hero guidelines</Text>
                        <Text variant="small" styles={helpfulTextStyles}>
                        Is this recommendation helpful?
                    <Card.Section styles={footerCardSectionStyles} tokens={footerCardSectionTokens}>
                        <Icon iconName="RedEye" styles={iconStyles} />
                        <Icon iconName="SingleBookmark" styles={iconStyles} />
                        <Stack.Item grow={1}>
                        <span />
                        <Icon iconName="MoreVertical" styles={iconStyles} />
  • Which version of office ui fabric have you included? What version of sfpx is your project on? Are you targeting SharePoint online?
    – baywet
    Nov 17 '19 at 0:49

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service, privacy policy and cookie policy

Browse other questions tagged or ask your own question.