jQuery UI Widgets Forums React Minimizing overhead of multiple files

This topic contains 1 reply, has 2 voices, and was last updated by  Hristo 4 years, 11 months ago.

Viewing 2 posts - 1 through 2 (of 2 total)
  • Author
  • Minimizing overhead of multiple files #107970

    walker1234
    Participant

    The following code has firstTab contents in a separate tsx file which is good. Just like that I can also have SecondTab contents in a separate file.

    https://stackblitz.com/edit/react-ts-y7i3rr?file=index.tsx

    So, if I have 20 tabs, I would need to have 20 different files.What would be an efficient approach to minimize this overhead?

    Also, in index.tsx, I would have 20 different case statements like this:

    private initWidgets = (tab: any) => {
        switch (tab) {
          case 0:
            render(<FirstTab />, this.gridElement.current!);
            break;
          case 1:
            this.initGrid2();
            break;
        }
      };

    Is it possible to loop through and generate these switch statements dynamically if I keep pulling case values dynamically?

    Minimizing overhead of multiple files #107977

    Hristo
    Participant

    Hello walker1234,

    This depends on the case.
    We do not have some hidden features for this.
    For example, if you have many similar grids inside the different tabs then you do not need to use the switch-case statement.
    You could use one function to initialize them depending on the case and to set there different sources (also, whatever properties are changed) – parameters for that function.

    Best Regards,
    Hristo Hristov

    jQWidgets team
    https://www.jqwidgets.com

Viewing 2 posts - 1 through 2 (of 2 total)

You must be logged in to reply to this topic.