Skip to content

Commit

Permalink
fix: use computed for params
Browse files Browse the repository at this point in the history
  • Loading branch information
EugeneBalabai committed Apr 15, 2024
1 parent 947e444 commit 24797ba
Showing 1 changed file with 8 additions and 7 deletions.
15 changes: 8 additions & 7 deletions packages/vue/src/T.ts
Original file line number Diff line number Diff line change
Expand Up @@ -4,7 +4,7 @@ import {
TranslateProps,
TranslationKey,
} from '@tolgee/web';
import { defineComponent, PropType, SetupContext } from 'vue';
import { defineComponent, PropType, SetupContext, computed } from 'vue';
import { useTranslateInternal } from './useTranslateInternal';

export const T = defineComponent({
Expand All @@ -22,13 +22,14 @@ export const T = defineComponent({
},
setup(props, context: SetupContext) {
const { slots } = context;
const { params } = props;
const slotsParams = {};
Object.keys(slots).forEach((key) => {
slotsParams[key] = slots[key]();
});
const assignedParams = Object.assign({}, params, slotsParams);
const { t } = useTranslateInternal();
const assignedParams = computed(() => {
const slotsParams = {};
Object.keys(slots).forEach((key) => {
slotsParams[key] = slots[key]();
});
return Object.assign({}, props.params, slotsParams);
});
return { t, assignedParams };
},
render() {
Expand Down

0 comments on commit 24797ba

Please sign in to comment.