Vladyslav Zavalykhatko
Vladyslav Zavalykhatko

Reputation: 17374

Why flow doesn't understand `export default`

Two instances of code:

const obj = {}
export default obj


export default obj = {}

Flow gives an error on the second

Cannot resolve name obj

Is there something wrong with the code in second place? It works just fine, but flow warns me.

Upvotes: 1

Views: 191

Answers (1)

Ritwick Dey
Ritwick Dey

Reputation: 19012

const obj = {
    // property goes here
}
export default obj

or,

export default {
   // property goes here
 }

or

let obj;
export default obj =  {
  // property goes here
}

Ref: https://developer.mozilla.org/en-US/docs/web/javascript/reference/statements/export

Upvotes: 4

Related Questions