Skip to content

Question: Is it ok for one slice to import another slice? #4672

@ChristophP

Description

@ChristophP

I am having circular dependency problems in my root reducer which TypeScript complains about. It reads like

Circular definition of import alias `sliceB`

from a very simplified version of this code.

import sliceA from './slice-a';
import sliceB from './slice-b'; // this line gives a TS error
import { combineReducers } from '@reduxjs/toolkit';

const rootReducer = combineReducers({ sliceA, sliceB });

My root suspect is that in the codebase some slices import others in order to build selectors that aggregate data from different slices.

So my question is ...

... is it even ok to use selectors of one slice in another slice? If not, what is the best way to structure selectors that compose values from multiple slices?

Things I already tried

  • Googling Circular definition of import alias but I couldn't find any description of what exactly causes this error
  • Narrowing it down more but the codebase is quite large and I wasn't able to narrow it down a significant amount of effort

Metadata

Metadata

Assignees

No one assigned

    Labels

    No labels
    No labels

    Type

    No type

    Projects

    No projects

    Milestone

    No milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions