onChange fn in folder item makes the item dissapears in get
Opened this issue · 4 comments
marospekarik commented
When I use the onChange function in an item in a folder, it will become unavailable in the get
function.
This is the example when adding the onChange function to the item in a folder makes the slicerEnabled
element unavailable in the get
function. Therefore: get('slicerEnabled'); will fail.
- When I remove the onChange function, I can retrieve the item with
get
- When I move the item outside of the folder, I can retrieve it with
get
const [{...controls}, set, get] = useControls( () => ({
"Boundary Conditions": folder({
inlet: {
value: 1.5,
min: 0.1,
max: 10,
parameterized: true
},
outlet: { value: true, parameterized: true },
}, { collapsed: false }, ),
"view": folder({
viewModeSelect: {
label: "View Mode",
options: {
"Point Cloud": 'PointCloud',
"Vector Fields": 'VectorFields',
"Surface Slices": 'SurfaceSlices',
"Streamline Slices": 'StreamlineSlices',
}
},
slicerEnabled: {
label: "Enable Slicer",
value: false,
parameterized: true,
onChange: (v) => setSlicerMode(v)
},
slicerVal: {
label: "Slice Y",
value: 1.5,
min: 0.1,
max: 10,
parameterized: true,
onChange: (v) => {
const isSlicerEnabled = get('slicerEnabled');
if(!isSlicerEnabled) {
... do my stufff
}
}
render: (get) => get('view.slicerEnabled') == true,
},
**ERROR:**
`Argument of type '"slicerEnabled"' is not assignable to parameter of type '"inlet" | "outlet" | "inlet_velocity" | "viewModeSelect" | "pointCloudSelect" | "pointCount" | "Message From PS"'.`
dbismut commented
Please provide a sandbox
marospekarik commented
Here you go:
https://codesandbox.io/s/eager-yonath-cbmf1i?file=/src/App.tsx
Happens only in TS environment
marospekarik commented
Did you manage to replicate the issue? @dbismut
dbismut commented
Indeed that's a bug, thanks for reporting it.