setOptionalProperties()
This hook replaces the current project's optional property data with the provided data.
Example
import { useRef } from "react";
import { Palito } from "../palito/Palito.jsx";
import exampleProperties from "./exampleProperties.json";
const ExamplePage = () => {
const palitoRef = useRef(null);
const LICENSE_KEY = "key-XXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXX";
const handleInjectData = () => {
if (palitoRef.current) {
palitoRef.current.setOptionalProperteis(exampleProperties);
}
};
return (
<div>
<div>
<Palito
ref={palitoRef}
licenseKey={LICENSE_KEY}
/>
</div>
{/* Add a button to test the API call */}
<div style={{ position: 'absolute', bottom: '40px', right: '20px', zIndex: 1000 }}>
<button onClick={handleInjectData} style={{ padding: '10px 20px', fontSize: '16px' }}>
Set Data
</button>
</div>
</div>
);
};
export default ExamplePage;
exampleProperties.json
[
{
"key": "Sample1",
"label": "Sample Property1"
},
{
"key": "Sample2",
"label": "Sample Property2"
}
]
Props
| Name | Type | Description | Default |
|---|---|---|---|
properties | { key: string; label: string; }[] | Array of objects containing optional node property information | - |
Return
This hook does not return any value.