react-jsmind-usage

Use when integrating @frank17008/react-jsmind npm package into React applications

Safety Notice

This listing is from the official public ClawHub registry. Review SKILL.md and referenced scripts before running.

Copy this and send it to your AI assistant to learn

Install skill "react-jsmind-usage" with this command: npx skills add frank17008/react-jsmind-usage

ReactJsMind Integration

Overview

React wrapper around jsMind for rendering interactive mind maps. Helps developers quickly integrate the npm package with correct imports, types, and configuration.

When to Use

  • Developer asks "how to install and use react-jsmind"
  • Developer reports "mind map not showing"
  • Developer needs ref methods (getData, addNode, screenShot)
  • Developer confused about data format or types

Installation

npm install @frank17008/react-jsmind
# or
yarn add @frank17008/react-jsmind

No need to install jsmind separately - it's a peer dependency.

Core Pattern - Basic Integration

import React, { useRef } from 'react'
import ReactJsMind from '@frank17008/react-jsmind'
import type { JsMindRefValue, JsMindData } from '@frank17008/react-jsmind'
import '@frank17008/react-jsmind/dist/esm/index.min.css' // REQUIRED for styling

const App = () => {
  const mindRef = useRef<JsMindRefValue | null>(null)

  // Correct data format - MUST include meta and format
  const mindData: JsMindData = {
    meta: { name: '思维导图', author: 'Your Name', version: '1.0' },
    format: 'node_tree',
    data: {
      id: 'root',
      topic: '中心主题',
      children: [
        { id: '1', topic: '分支1' },
        { id: '2', topic: '分支2' },
      ],
    },
  }

  return (
    <div style={{ width: '100%', height: 600 }}>  // REQUIRED: parent must have explicit size
      <ReactJsMind
        ref={mindRef}
        data={mindData}
        options={{ editable: true }}
        onClick={(node) => console.log('Clicked:', node)}
      />
    </div>
  )
}

export default App

Quick Reference

Types (import from @frank17008/react-jsmind)

TypeUsage
JsMindRefValueRef type for useRef
JsMindDataData object with meta/format/data
TreeNodeSingle node with id/topic/children
ArrayTreeNodeArray format node with parentid

Ref Methods

mindRef.current?.getData()           // Get current data
mindRef.current?.getSelectedNode()   // Get selected node
mindRef.current?.screenShot()        // Export as PNG
mindRef.current?.expandAll()         // Expand all nodes
mindRef.current?.addNode(parent, 'id', 'topic', {}, 'right')  // Add node
mindRef.current?.removeNode(node)   // Remove node
mindRef.current?.setNodeColor(nodeId, '#ff0000', '#ffffff')   // Set colors

Data Formats

  • Tree format (node_tree): { id, topic, children: [...] }
  • Array format (node_array): { id, topic, parentid } with isroot for root

Common Mistakes

Mistake 1: Missing CSS Import

// ❌ WRONG - no styling
import ReactJsMind from '@frank17008/react-jsmind'

// ✅ CORRECT
import ReactJsMind from '@frank17008/react-jsmind'
import '@frank17008/react-jsmind/dist/esm/index.min.css'

Mistake 2: Wrong Type Name

// ❌ WRONG
const ref = useRef<JsMindRef>(null)

// ✅ CORRECT
const ref = useRef<JsMindRefValue | null>(null)

Mistake 3: Missing Container Size

// ❌ WRONG - container has no size
<ReactJsMind data={data} />

// ✅ CORRECT - parent must have explicit width/height
<div style={{ width: '100%', height: 600 }}>
  <ReactJsMind data={data} />
</div>

Mistake 4: Incomplete Data Object

// ❌ WRONG - passing TreeNode directly
<ReactJsMind data={{ id: 'root', topic: 'Root' }} />

// ✅ CORRECT - wrap in JsMindData with meta and format
<ReactJsMind data={{
  meta: { name: 'demo' },
  format: 'node_tree',
  data: { id: 'root', topic: 'Root' }
}} />

Data Format Examples

Tree Format (Recommended)

const data: JsMindData = {
  meta: { name: 'My Mind Map', version: '1.0' },
  format: 'node_tree',
  data: {
    id: 'root',
    topic: 'Main Topic',
    expanded: true,
    children: [
      { id: '1', topic: 'Child 1', direction: 'left' },
      { id: '2', topic: 'Child 2', direction: 'right', children: [
        { id: '2-1', topic: 'Grandchild' }
      ]},
    ],
  },
}

Array Format

const data: JsMindData = {
  meta: { name: 'My Mind Map' },
  format: 'node_array',
  data: [
    { id: 'root', topic: 'Main', parentid: null, isroot: true },
    { id: '1', topic: 'Child 1', parentid: 'root' },
    { id: '2', topic: 'Child 2', parentid: 'root' },
  ],
}

Troubleshooting

"Mind map not showing"

  1. Check parent container has explicit width/height
  2. Verify CSS is imported: import '@frank17008/react-jsmind/dist/esm/index.min.css'
  3. Ensure data format includes meta and format fields

"TypeScript errors"

  1. Use JsMindRefValue not JsMindRef
  2. Import types: import type { JsMindRefValue, JsMindData } from '@frank17008/react-jsmind'

"screenShot not working"

  1. Ensure container has rendered first
  2. Check dom-to-image dependency is installed

Source Transparency

This detail page is rendered from real SKILL.md content. Trust labels are metadata-based hints, not a safety guarantee.

Related Skills

Related by shared tags or category signals.

General

evens-结算

AI驱动的智能结算助手,支持话题词精准识别、自然语言规则解析、规则确认流程、多种结算模式(达标瓜分/排名赛/混合模式),数据本地处理保障安全。触发词:「一组结算」「帮我结算」「请结算」「结算活动」。

Registry SourceRecently Updated
General

Model Switch

OpenClaw 一键切换AI模型技能。懒人触发词:切到xxx、当前模型、模型问题、添加/移除模型、模型对比/列表。解决"切换模型后为什么总是失败"的痛点。

Registry SourceRecently Updated
General

飞书文档翻译助手

飞书文档翻译助手 — 在飞书文档之间进行中英文互译,支持全文翻译、段落翻译、双语对照。当用户需要翻译飞书文档、英文文档转中文、中文文档转英文、或创建双语版本文档时使用。触发词:翻译飞书文档、文档翻译、中英互译、双语文档、translate feishu doc、飞书英文。

Registry SourceRecently Updated
General

Stock Terminal

Provides Bloomberg-style synthesized stock and market reports via typed commands like open, compare, daily brief, mood, screen smart-money, flow, and news, a...

Registry SourceRecently Updated