Closed
Description
What docs page needs to be fixed?
- Updating Post Entries:
- Redux Essentials, Part 4: Using Redux Data:
What is the problem?
On the Redux Essentials, Part 3: Basic Redux Data Flow page, the user is told to create this initial state containing integer ids:
const initialState = [
{ id: 1, title: 'First Post!', content: 'Hello!' },
{ id: 2, title: 'Second Post', content: 'More text' }
]
However, later on in the tutorial, the user is told to create a SinglePostPage
that compares a route parameter (a string) with each post id. Because a triple equals sign is used and type conversion doesn't happen, the original data will always show the not found page. New data works just fine, but old data does not.
What should be changed to fix the problem?
The selector code should be:
const post = useSelector(state =>
state.posts.find(post => post.id.toString() === postId)
)
Metadata
Metadata
Assignees
Labels
No labels