Skip to content

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

@whitetrefoil

Description

@whitetrefoil
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

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