pcf-react
A PowerApps Component Framework React starter kit
PCF Installation
Get tooling for Power Apps component framework
Project creation steps
- md ProjectName & cd ProjectName
- pac pcf init --namespace <> --name <> --template <>
- npm i & npm run build
- edit tsconfig.json
- add "noImplicitAny": false to compilerOptions
- install npms
- npm i @types/node @types/jest @types/powerapps-component-framework @uifabric/icons office-ui-fabric-react react react-dom
- npm i -D @babel/core @babel/preset-env @babel/preset-react @storybook/addon-actions @storybook/addon-jest @storybook/addon-storyshots @storybook/react @typescript-eslint/eslint-plugin @typescript-eslint/parser babel-eslint babel-jest babel-loader babel-plugin-add-module-exports babel-plugin-require-context-hook eslint eslint-config-airbnb eslint-config-prettier eslint-plugin-import eslint-plugin-jsx-a11y eslint-plugin-prettier eslint-plugin-react eslint-plugin-react-hooks jest jsdoc prettier react-test-renderer
- copy .eslintrc.json, .gitignore, babel.config.js, jest.config.js and jsdoc.json
- copy the .jest & .storybook configuration folders
- copy test/storyShots.test.js to your test folder
- copy stories/jest.stories.js to your stories folder
- Copy the scripts section of package.json
Project deploy file creation steps
- md deploy & cd deploy (in ProjectName folder)
- pac solution init --publisher-name <> --publisher-prefix <>
- pac solution add-reference --path ..\
- edit deploy\Other\Solution.xml
- UniqueName
- LocalizedName description="" languagecode="1033"
- msbuild /t:build /restore /p:configuration=Release
Architectural notes
This project views the index.ts as a "wrapper". It only hosts the actual SamplePCF and passes the parameters as props. For more complicated controls, I would recommend using the redux toolkit and expose the appropriate actions. If you are using actions then there is no need to do the ReactDOM.render in updateView. You may however need to consider when setDisabled or setVisible is called on the control. You can get these values from the context object.
- context.mode.isControlDisabled
- context.mode.isVisible
Stores
- XState - JavaScript and TypeScript finite state machines and statecharts for the modern web.
- Redux Toolkit - The official, opinionated, batteries-included toolset for efficient Redux development
- MobX - Simple, scalable state management
Web Workers
It is actually very simple to add web workers into pcf. You can use the example in Google Webworker Plugin to test this feature.
- npm i -D worker-plugin
- edit webpackConfig.js in node_modules\pcf-scripts
- add at line 2 const WorkerPlugin = require('worker-plugin');
- add at line 76 plugins: [new WorkerPlugin()]
Core Packages
Design, Documentation, Type Checking & Lint
Testing
References
- Power Apps component framework API reference
- Use of React and Office UI Fabric React in the PowerApps component framework is now available for public preview
- Create and build a code component
- Package a code component
- Develop your custom controls using Power Apps Component framework and use it on your CRM interface.
- Create Custom Controls using PowerApp Component Framework
- Create a React component library with TypeScript and Storybook
- 5 Ways to Document React Components in 2020
- Comparing React testing libraries
- Static vs Unit vs Integration vs E2E Testing for Frontend Apps
- 5 Tips to Improve the Performance of Your React Apps