2020-11-08 23:13:49 -05:00
# Adaptive Cards using React Hooks
2020-04-27 22:26:44 -04:00
## Summary
A version of [react-adaptivecards ](https://github.com/SharePoint/sp-dev-fx-webparts/tree/master/samples/react-adaptivecards ) using React Hooks.
![Adaptive Cards in SharePoint ](assets/preview.png )
## Used SharePoint Framework Version
2020-08-25 21:44:20 -04:00
![1.11.0 ](https://img.shields.io/badge/version-1.11.0-green.svg )
2020-04-27 22:26:44 -04:00
## Applies to
2020-06-09 03:09:22 -04:00
* [SharePoint Framework ](https://docs.microsoft.com/sharepoint/dev/spfx/sharepoint-framework-overview )
* [Office 365 tenant ](https://docs.microsoft.com/sharepoint/dev/spfx/set-up-your-development-environment )
2020-04-27 22:26:44 -04:00
## Solution
Solution|Author(s)
--------|---------
react-adaptivecards-hooks | Paul Schaeflein (http://www.schaeflein.net)
2020-08-25 23:09:22 -04:00
react-adaptivecards-hooks | Hugo Bernier ([Tahoe Ninjas](https://tahoeninjas.blog), [@bernier ](https://twitter.com/bernierh ))
2020-04-27 22:26:44 -04:00
## Version history
Version|Date|Comments
-------|----|--------
1.0|April 27, 2020|Initial release
2020-08-25 21:44:20 -04:00
2.0|August 25, 2020|Upgraded to SPFx 1.11 and added support for May 2020 changes to Adaptive Cards
2020-04-27 22:26:44 -04:00
## Disclaimer
**THIS CODE IS PROVIDED *AS IS* WITHOUT WARRANTY OF ANY KIND, EITHER EXPRESS OR IMPLIED, INCLUDING ANY IMPLIED WARRANTIES OF FITNESS FOR A PARTICULAR PURPOSE, MERCHANTABILITY, OR NON-INFRINGEMENT.**
---
## Minimal Path to Awesome
* Clone this repository
* in the command line run:
* `npm install`
* `gulp serve`
2020-04-27 21:50:30 -04:00
### Code structure
| File | Type | Description |
|------------------------------|--------------------------------------------------|----------------|
| AdaptiveCardViewerWebPart.ts | React Class component (derives from BaseWebPart) | Used to define web part properties and bootstrap the component tree|
2021-04-26 02:08:59 -04:00
| RootComponent.tsx | React Function component | Interrogates web part properties and establishes AppContext and initial state.< br / > Monitors CardService state and dispatches updates to viewer state. |
| AppContext.ts | React context provider | Exposes the SPFx web part context, the web part instance and the state dispatch to all components via `React.useContext()` |
2020-04-27 21:50:30 -04:00
| CardService.ts | React Hook | Abstracts the SP HttpClient |
| CardServiceReducer.ts | React Reducer | Reducer/state for CardService hook |
| AdaptiveCardViewer.tsx | React Function component | Top-level UI component. |
| AdaptiveCardHost.tsx | React Function component | Renders placeholder if template/data are missing. Handles card actions. |
| AdaptiveCard.tsx | React Class component | Responsible for rendering adaptive card and expanding card with data |
2020-04-27 22:26:44 -04:00
< img src = "https://telemetry.sharepointpnp.com/sp-dev-fx-webparts/samples/react-adaptivecards-hooks" / >