swamp blues
swamp blues

Reputation: 313

How to collect multiple named ES6 exports in one named export?

I'm using code from the official documentation. You can find it here

This is the relevant line:

export const { increment, decrement, incrementByAmount } = counterSlice.actions

I want to export all the slice reducers without explicitly having to type their names. I want to do this because as the number of reducers increases it becomes cumbersome to maintain the export statement updated to reflect all the CRUD operations I might do on the slice reducers.

Upvotes: 0

Views: 131

Answers (1)

timotgl
timotgl

Reputation: 2925

Credit goes to https://stackoverflow.com/users/6546440/rashomon

export const actions = todoSlice.actions;
// import it as:
import { actions } from 'your-file';

Upvotes: 2

Related Questions