2

I have a LWC that, for other some users, it is not behaving as expected, and the following code:

    _setActionsColumn() {
        if (this.actions && this.actions.length > 0) {
            this.columns = [
                ...this.columns,
                {
                    type: 'action',
                    fixedWidth: 62,
                    typeAttributes: { rowActions: this.actions }
                }
            ];
        }
    }

is rendering as "0" in the browser console.

I tried Users > find the user with the problem > login as

But still, like this I am not facing any issue

3
  • 1
    I am completely confused about the code snippet above and user context. How is the above code dependant on logged in user. – Nagendra Singh Apr 13 at 13:01
  • It is not at all. Thats the funny thing. Hence my question – Gabriel Serrano Salas Apr 13 at 14:09
  • I renamed the title since, now that we do know what the problem was, it is more accurate IMHO – Gabriel Serrano Salas Apr 13 at 14:29
5

While "Login As" feature did not work to reproduce the issue, actually login as that user with its credentials did.

After that, I came to this conclusion:

Normally, LWC engine will parse and transform any latest syntax, lets say ES20 features, and convert it into something readable by the client browser if it is not supported already, however, apparently this only works in the main class module, where you extend LinghtningElement.

If you are splitting your code into modules and exporting objects/functions from there, and those functions use that features, these latest features may not work properly as expected. In my case, even in the same computer and browser, I just faced a different behaviour when login in as a completely different user (not even using login as). This was solved by replacing "foo?.bar" by a more widely supported approach of "foo && foo.bar"

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service, privacy policy and cookie policy

Not the answer you're looking for? Browse other questions tagged or ask your own question.