Skip to content

Instantly share code, notes, and snippets.

Created January 29, 2022 02:54
  • Star 0 You must be signed in to star a gist
  • Fork 0 You must be signed in to fork a gist
Star You must be signed in to star a gist
Save ksakae1216/1118b9c4ac794faf14fd913456f7ea08 to your computer and use it in GitHub Desktop.
import { createSelector, createFeatureSelector } from '@ngrx/store';
// <{ isLogin: boolean, errorMessage: string }>はstoreの型、reducerに書いたやつ
// 'LoginState'はキー。好きな名前でOK
export const selectFeature = createFeatureSelector<{ isLogin: boolean, errorMessage: string }>('LoginState');
// getIsLoginというselectorを作成し、storeからisLoginを取得
export const getIsLogin = createSelector(
(state) => state.isLogin
// getErrorMessageというselectorを作成し、storeからerrorMessageを取得
export const getErrorMessage = createSelector(
(state) => state.errorMessage
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment