0
0

Delete article

Deleted articles cannot be recovered.

Draft of this article would be also deleted.

Are you sure you want to delete this article?

More than 3 years have passed since last update.

「Goqoo on kintone」で Reactを使う方法

Last updated at Posted at 2022-01-27

概要

Goqoo on kintone を使って、kintoneカスタマイズの React開発環境を構築する方法について書きます。

Goqoo on kintone については下記の公式記事を参照ください。
https://qiita.com/the_red/items/3222d8bf71c32d769060

環境

  • macOS 10.15.7

goqoo new

適当なディレクトリを作成して、下記を実行。

npx goqoo new プロジェクト名

「Frontend Framework」は (None) を選択。

プロジェクトが生成されたら、プロジェクトディレクトリにcdして、git commitします。

goqoo generate

カスタマイズに必要な雛形のファイル等を生成します。

npx goqoo generate app アプリ名

$ npx goqoo generate app app305
✔ App name · app305
info Created src/apps/app305/index.ts
info Created src/apps/app305/hello.ts

srcディレクトリ以下はこんな感じになっています。

$ tree -L 3 ./src
./src
├── apps
│   └── app305
│       ├── hello.ts
│       └── index.ts
├── context.ts
├── example.ts
├── in-app
└── types.ts

Reactパッケージのインストール

React関連のパッケージをインストールします。

package.jsonにパッケージを登録して、npm installします。

  "devDependencies": {
    "@types/bootstrap": "^5.1.0",
    "@types/react": "^17.0.15",
    "@types/react-dom": "^17.0.9",
・・・ 
  "dependencies": {
    "bootstrap": "^5.1.0",
    "react": "^17.0.2",
    "react-dom": "^17.0.2",
・・・

TSXファイルの作成

アプリフォルダの「hello.ts」を書き換えます。

hello.tsx
import type { IndexEvent } from 'types'
import * as React from "react"
import * as ReactDOM from "react-dom"

const App = () => (<span> Hello from Goqoo on kintone!!!!!!! </span>)

kintone.events.on('app.record.index.show', async (event: IndexEvent<any /* kintone.types.SavedXxxxFields */>) => {
  const container = document.getElementById('react-sample-container')
  ReactDOM.render(<App />, container)
  return event
})

goqoo.config.js修正

「bundlerType:」を'react' に書き換えます。

const config = {
  // bundlerType: 'default',
  bundlerType: 'react',

goqoo start

npx goqoo start して確認します。

スクリーンショット 2022-01-27 13.21.42.png

※事前にカスタマイズビューを作成して、<div id='react-sample-container'></div>を設定しておきます。

0
0
3

Register as a new user and use Qiita more conveniently

  1. You get articles that match your needs
  2. You can efficiently read back useful information
  3. You can use dark theme
What you can do with signing up
0
0

Delete article

Deleted articles cannot be recovered.

Draft of this article would be also deleted.

Are you sure you want to delete this article?