Skip to content

Conversation

brojor
Copy link
Contributor

@brojor brojor commented Oct 19, 2022

Title and subtitle of <ATypography /> are not reactive.

Expected behavior:

Kapture 2022-10-19 at 19 56 30

Current behavior:

Kapture 2022-10-19 at 19 53 02

@netlify
Copy link

netlify bot commented Oct 19, 2022

Deploy Preview for anu-vue ready!

Name Link
🔨 Latest commit 16ef454
🔍 Latest deploy log https://app.netlify.com/sites/anu-vue/deploys/6354e12457c5000008716212
😎 Deploy Preview https://deploy-preview-49--anu-vue.netlify.app
📱 Preview on mobile
Toggle QR Code...

QR Code

Use your smartphone camera to open QR code link.

To edit notification comments on pull requests, go to your Netlify site settings.

@jd-solanki
Copy link
Owner

Thanks for the PR!

You can reuse useConfigurable composable instead of creating computeContentAndClasses in typography.

Feel free to update types of useConfigurable if required.

Thanks.

@brojor
Copy link
Contributor Author

brojor commented Oct 21, 2022

Thanks, I didn't know about useConfigurable.
The problem is that useConfigurable returns a plain object instead of a reactive ref object. Can I modify it?

@jd-solanki
Copy link
Owner

Can I modify it?

Yes, why not 😇

@jd-solanki
Copy link
Owner

If possible, follow vueuse like convention: { someRef, someRef } = useSomeComposable

@brojor
Copy link
Contributor Author

brojor commented Oct 21, 2022

I just want to add computed:

export const useConfigurable = (value: MaybeRef<ConfigurableValue>) => computed(() => {
  const _value = resolveUnref(value)

  const [content, classes, attrs] = _value === undefined
    ? []
    : typeof _value === 'string' || typeof _value === 'number'
      ? [_value]
      : _value

  return { content, classes, attrs }
})

@jd-solanki
Copy link
Owner

make sure to test if we destructure via { content, classes, attrs } = useConfigurable(...).value, content & other destructured values are reactive.

@brojor
Copy link
Contributor Author

brojor commented Oct 21, 2022

The problem is that useConfigurable returns a plain object instead of a reactive ref object.

I just want to add computed

I thought that if we add computed to useConfigurable we would be able to use it instead of computeContentAndClasses, but it doesn't work. We're still losing reactivity somewhere.
I'll try to figure out where.

@brojor
Copy link
Contributor Author

brojor commented Oct 21, 2022

Now it works (reactivity is preserved even when using useConfigurable). But destructuring gives primitive values.

I tried using toRefs as a return value of useConfigurable. Then we get refs when destructuring, but the ref values don't change 😕

@jd-solanki
Copy link
Owner

Hi 👋🏻

Thanks for the useful PR

I just removed the usage of reduce because it was a bit confusing or harder to understand at first. Moreover, I have updated prop type as well.

Thanks so much

@jd-solanki jd-solanki merged commit 05d0afa into jd-solanki:main Oct 23, 2022
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

Successfully merging this pull request may close these issues.

2 participants