investtools / extensible-duck

Modular and Extensible Redux Reducer Bundles (ducks-modular-redux)

Geek Repo:Geek Repo

Github PK Tool:Github PK Tool

Unable to import parts of the Duck

kbrandwijk opened this issue · comments

I wanted to use the syntax import { creators } from './MyDuck', but creators turns up undefined.
I can use import MyDuck from './MyDuck' and use MyDuck.creators, but it would be nice if I could only import the parts that I need (for example, only import types in my sagas, only import creators in my Containers, etc.

Hi @kbrandwijk

extensible-duck cannot control what is exported by your js file, nevertheless you can do the following:

const MyDuck = new Duck(...)
export default MyDuck
export const creators from MyDuck

@akelmanson Thank you. However, with export default MyDuck, and creators and types being properties on the Duck, import { creators, types } from './MyDuck' normally works. Is there anything special about the class that makes it return undefined?

@kbrandwijk Can you give me an example using a plain js object?