React for Zendesk App Framework V2.0
NPM: Direct from NPM or install with Homebrew
$ brew install node
Add this line to your application's Gemfile:
gem 'zaf_react'
And then execute:
$ bundle
Or install it yourself as:
$ gem install zaf_react
$ zafr init
This will generate a very basic React app with an example component "src/components/item-list/item-list.js".
$ zafr start
This will run the React server on localhost:3000.
$ zafr build
This will compile the React app into a production ready build. This will not run if uploaded to Zendesk. See below.
$ zafr server
This will run the previous zafr build
command, then start the ZAT Server for local testing in Zendesk. See Zendesk's docs here for using the ZAT server here.
$ zafr validate
This will run the zat validate
command in the /build
directory to validate the ZAF V2.0 App.
$ zafr package
This will run the above zafr build
command, then flatten the React assets directory structure, and finally compile the entire app into a ZAF V2.0 app ready for upload to Zendesk. The uploadable .zip file can be found at /build/tmp/app-{timstamp}.zip
.
Zendesk's ZAFClient is not available outside of Zendesk. In order to allow local testing, without any need for Zendesk, use the file /source/src/zendesk/helpers/zaf_test_client.js
. There you can build methods to simulate the ZAFClient functionality away from the Zendesk environment. The ZAF Test Client will not be used when uploaded to Zendesk or when using the ZAT Server.
During the zafr package
command, all React style and js assets will be flattened and moved from /build/assets/static/*
to /build/assets/*
as ZAF V2.0 does not allow a nested file structure.
Bug reports and pull requests are welcome on GitHub at https://github.com/onlyexcellence/zaf_react.