agentsclimarketplace

React jsmind usage

Skill Frank17008/skills/react-jsmind-usage

Use when integrating @frank17008/react-jsmind npm package into React applicationsFrom its SKILL.md

Install
npx -y skills add Frank17008/skills --skill react-jsmind-usage

Assembled from the repository path, not quoted from the project. Check it against their README if it does not work.

2 things to look at

  • no licenseNo license file was found in the repository. Code published without one is not open source by default, so using it at work is a question for whoever answers licensing questions where you are.
  • 0 stars0 stars. Stars are a popularity signal and not a quality one, but at this level it is likely that nobody has read this closely except its author, and you would be relying on your own review.

SKILL.md

4.8 KB, ~1.4k tokens by cl100k_base, as published. Nobody here has run it

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

What ships with it

Read from the repository

Just SKILL.md. No reference files, no scripts.

Keep looking

Skills are one crate of 326,401. Ordering is by how many stacks a row turns up in, so the top of any crate is what has actually been picked rather than what has the most stars.