Skip to content

Instantly share code, notes, and snippets.

What would you like to do?
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