0

I've got a component that was used in the column of ag-grid-community. After moving vue app from lerna to NX, the component works differently - the .data property, that contained some data in lerna, is empty now. No significant changes were made to the app itself, some only some webpack configuration was added to handle css. How can I fix it? Or if I can't, how can I do it in a different way to make it work again?

Here is the component code:

    // listColumns.ts used to configure ag-grid
    export const columns = {
      // ...
      actions: {
        field: 'actions',
        headerName: 'Actions',
        cellRenderer: 'Action',
      },
    }
    
    
    // Actions.vue
    type Params = {
      data: any;
      value: ActionDefinition[];
    };
    
    type ActionDefinition = {
      icon: string;
      alt: string;
      onClick: (data?: any) => void;
    };
    
    export default defineComponent({
      name: 'Action',
      setup() {
        const isLoading = ref(true);
        const rowData = ref<any>(null);
        const actions = ref<ActionDefinition[] | null>(null);
    
        // I've tried to put it here, with no luck
        // const instance = getCurrentInstance();
        
        onMounted(() => {
          const instance = getCurrentInstance();
          if (instance && !isEmpty(instance.data)) { // instance.data is empty - instance.data == {}
            const {data, value} = instance.data.params as Params;
            rowData.value = data;
            actions.value = value;
            isLoading.value = false;
          }
        });
    
        return {isLoading, rowData};
      },
    });

akkonrad
  • 1,043
  • 1
  • 10
  • 25
  • 2
    `getCurrentInstance` is internal (and currently undocumented) API and [exposes internal instance](https://github.com/vuejs/docs/issues/1422#issuecomment-1032120675) *that exposes non-public APIs. Anything you use from that instance can technically break between any release types, since they are not subject to semver constraints.* **Do not use it!** – Michal Levý May 17 '22 at 17:18

0 Answers0