Skip to content

This issue was moved to a discussion.

You can continue the conversation there. Go to discussion →

New issue

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

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

Already on GitHub? Sign in to your account

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

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

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
@reduxjs reduxjs locked and limited conversation to collaborators Nov 23, 2024
@markerikson markerikson converted this issue into discussion #4727 Nov 23, 2024

This issue was moved to a discussion.

You can continue the conversation there. Go to discussion →

Labels
None yet
Projects
None yet
Development

No branches or pull requests

1 participant