0

I may be confusing OO with JS modules but I want to do something like this:

export default {
    functionA:()=>{
        this.functionB
    },
    functionB:()=>{
        console.log('Hello from functionB')
    },
}

then:

import pc from 'path/to/pc'

pc.functionA

desired result: 'Hello from functionB'

actual result: TypeError: Cannot read property 'functionB' of undefined

What is the correct way to do this?? Is it even possible? Any help would be greatly appreciated.

Brad
  • 8,044
  • 10
  • 39
  • 50
  • haha, just scrolled up lol – Brad Oct 19 '18 at 02:40
  • I struggle to understand how that answers my question, my question is about exporting modules, not about how to use arrow functions... – Brad Oct 19 '18 at 02:42
  • Ah ok, I understand, because the arrow function does not scope this the same thats why i get my problem, i changed to regular functions and all good. Thanks mate. – Brad Oct 19 '18 at 02:45

0 Answers0