reduxjs / redux

A JS library for predictable global state management
https://redux.js.org
MIT License
60.94k stars 15.27k forks source link

Missing defintion of selectCurrentUsername #4724

Closed mattbal closed 3 months ago

mattbal commented 3 months ago

What docs page needs to be fixed?

https://redux.js.org/tutorials/essentials/part-4-using-data#adding-the-login-page

What is the problem?

The documentation is missing a code block showing the selector selectCurrentUsername being defined. Right now, if you read through the section Adding the Login Page, the code block for App.tsx imports selectCurrentUsername from './features/auth/authSlice'. But if you look at the most recent code block defining authSlice, there is no definition for that selector included.

What should be changed to fix the problem?

There's two options:

  1. Create a new code block beneath the App.tsx code block, showing selectCurrentUsername being defined:
// features/auth/authSlice.ts
export const selectCurrentUsername = (state: RootState) => state.auth.username

Or,

  1. Update the original authSlice codeblock to include this:
// features/auth/authSlice.ts
export const selectCurrentUsername = (state: RootState) => state.auth.username