Published on

d3

If you need to use D3 and your code is turning into a mess, try organizing it with composable functions.

js
export function useD3(refName, cb = () => {}) {
  const refSelector = useTemplateRef(refName)
  watchPostEffect(() => cb(select(toValue(refSelector))))
}

example