본문으로 건너뛰기

setVersion()

이 Hook은 특정 버전으로 현재 버전정보를 교체합니다.


Example

import { useRef } from "react";
import { Palito } from "../palito/Palito.jsx";
import example from "./example.json";

const ExamplePage = () => {
const palitoRef = useRef(null);
const LICENSE_KEY = "key-XXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXX";

const handleInjectData = () => {
if (palitoRef.current) {
palitoRef.current.setVersion(1.0);
}
};

return (
<div>
<div>
<Palito
ref={palitoRef}
licenseKey={LICENSE_KEY}
initialProject={example}
/>
</div>
{/* API 호출을 테스트하기 위한 버튼 추가 */}
<div
style={{
position: "absolute",
bottom: "40px",
right: "20px",
zIndex: 1000,
}}
>
<button
onClick={handleInjectData}
style={{ padding: "10px 20px", fontSize: "16px" }}
>
Set Version (1.1 to 1.0)
</button>
</div>
</div>
);
};

export default ExamplePage;

example.json

{
"projectName": "Sample Project",
"shipName": "Sample Ship",
"compName": "Sample Company",
"optionalFields": [],
"versions": [
{
"version": 1,
"versionMemo": "Sample Version (Example Target)",
"editTime": "2025-09-16 16:13:16",
"zones": [
{
"id": "zone-1",
"name": "Zone 1",
"nodes": [
{
"id": "1",
"type": "custom",
"position": {
"x": 20,
"y": 270
},
"data": {
"component_name": "Firewall",
"type": "Firewall",
"security_zone": "zone-1",
"system_category": "Network",
"other_system_connection": [
{
"id": "2",
"type": "Default"
}
]
},
"measured": {
"width": 80,
"height": 100
},
"selected": false,
"dragging": false
},
{
"id": "2",
"type": "custom",
"position": {
"x": 20,
"y": 20
},
"data": {
"component_name": "Router",
"type": "Router",
"security_zone": "zone-1",
"system_category": "Network",
"other_system_connection": []
},
"measured": {
"width": 80,
"height": 100
},
"selected": false
}
],
"viewport": {
"x": 0,
"y": 0,
"zoom": 1
},
"flag": true
}
]
},
{
"version": 1.1,
"versionMemo": "Sample Version",
"editTime": "2025-09-16 16:13:11",
"zones": [
{
"id": "zone-1",
"name": "Zone 1",
"nodes": [
{
"id": "1",
"type": "custom",
"position": {
"x": 20,
"y": 270
},
"data": {
"component_name": "Firewall",
"type": "Firewall",
"security_zone": "zone-1",
"system_category": "Network",
"other_system_connection": [
{
"id": "2",
"type": "Default"
}
]
},
"measured": {
"width": 80,
"height": 100
},
"selected": false,
"dragging": false
},
{
"id": "2",
"type": "custom",
"position": {
"x": 120,
"y": 20
},
"data": {
"component_name": "Router",
"type": "Router",
"security_zone": "zone-1",
"system_category": "Network",
"other_system_connection": []
},
"measured": {
"width": 80,
"height": 100
},
"selected": false
},
{
"id": "3",
"type": "custom",
"position": {
"x": 220,
"y": 270
},
"data": {
"component_name": "Firewall",
"type": "Firewall",
"security_zone": "zone-1",
"system_category": "Network",
"other_system_connection": [
{
"id": "2",
"type": "Default"
}
]
},
"measured": {
"width": 80,
"height": 100
}
}
],
"viewport": {
"x": 0,
"y": 0,
"zoom": 1
},
"flag": true
}
]
}
]
}

Props

이름유형설명기본값
versionIdnumber선택하려는 버전의 값 (예: 1.0, 1.1)-

Return

이 Hook은 Return 값을 받지 않습니다.