集成了 OCAP JS SDK 的 React 种子项目,使用 create-react-app 初始化。
For English documentation, please checkout README.md
需要安装 npm v6+,自带了 npx 命令,直接使用如下命令初始化项目:
npx create-react-app my-ocap-app --scripts-version @arcblock/react-scripts
cd my-ocap-app
yarn start
git clone https://github.com/ArcBlock/ocap-react-starter.git
cd ocap-react-starter
yarn
yarn serve
如果是国内开发者,建议使用淘宝源安装依赖:
yarn --registry=https://registry.npm.taobao.org
- SDK 初始化和封装:src/libs/ocap.js
- 使用 SDK 做查询:src/pages/Query/index.js
- 使用 SDK 做实时数据订阅:src/pages/Subscription/index.js
如果看到这里,恭喜你,马上就可以把项目部署到公网,给大家试用了,我们建议使用 now.sh 部署应用,步骤如下:
- 到 https://zeit.co 创建账号
- 安装 zeit cli:
npm install -g now
- 登录 zeit-cli,
now login
- 在 deploy.sh 中设置项目的域名 alias
- 执行
npm run deploy
部署成功!很期待你的应用出现在我们的 APP Gallery 里面。