Skip to content
New issue

Have a question about this project? # for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “#”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? # to your account

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

Open
ChristophP opened this issue Oct 21, 2024 · 0 comments
Open

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

ChristophP opened this issue Oct 21, 2024 · 0 comments

Comments

@ChristophP
Copy link

ChristophP commented Oct 21, 2024

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
# for free to join this conversation on GitHub. Already have an account? # to comment
Labels
None yet
Projects
None yet
Development

No branches or pull requests

1 participant