onClick function in react-three-fiber mesh when mesh layer is set

I am new to react-three-fiber.

<mesh ref={ref} layers={1} name="archMesh" visible={props.visible} onClick={handleClick} >

In above mesh, handleClick is not triggering when layers is set.

could you make a codesandbox with the behaviour. just seeing that line isn’t enough.

i saw cody post about this yesterday. in threejs you need to tell the raycaster about layers or else it won’t raycast them.

const raycaster = useThree(state => state.raycaster)