Skip to content
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

injectedSlice.selectors seems doesn't handle uninjected problem like .getSelectors() & .selectSlice() #4054

Closed
whitetrefoil opened this issue Jan 9, 2024 · 1 comment

Comments

@whitetrefoil
Copy link

whitetrefoil commented Jan 9, 2024

export interface State {
  initializing?: true
}

export const lazySlice = createSlice({
  name: 'friends',
  initialState: {} as State,
  reducers: create => ({
    INIT: create.reducer(s => {
      s.initializing = true
    }),
    // ...
  }),
  selectors: {
    $isInitializing: s => s.initializing === true,
  },
})

export const injectedSlice = lazySlice.injectInto(rootReducer)

console.log(injectedSlice.selectSlice({}))
// => {}
console.log(injectedSlice.getSelectors(s => s.friends).$isInitializing({}))
// => false
console.log(injectedSlice.selectors.$isInitializing({}))
// => Uncaught Error: selectSlice returned undefined for an uninjected slice reducer
@EskiMojo14
Copy link
Collaborator

thanks for the report! I've replicated the issue in tests, and raised #4056 to fix it. that'll create a codesandbox build you can use in the meantime, and we'll try to get it merged and released when we can :)

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

Successfully merging a pull request may close this issue.

2 participants