Answer the question
In order to leave comments, you need to log in
How does normalizr work?
{
"id": "123",
"author": {
"id": "1",
"name": "Paul"
},
"title": "My awesome blog post",
"comments": [
{
"id": "324",
"commenter": {
"id": "2",
"name": "Nicole"
}
}
]
}
import { normalize, schema } from 'normalizr';
// Define a users schema
const user = new schema.Entity('users');
// Define your comments schema
const comment = new schema.Entity('comments', {
commenter: user
});
// Define your article
const article = new schema.Entity('articles', {
author: user,
comments: [comment]
});
const normalizedData = normalize(originalData, article);
Answer the question
In order to leave comments, you need to log in
reduces the nesting of objects
https://habr.com/en/post/332628/
Such a structure is easy to read, easy to run a foreach loop through projects, render subcomponents with layer lists, and so on. But suppose we want to change the title of the page from id:1. Inside some small component that renders the page, $store.dispatch("changePageName",{id:1,name:"new name"}) is called. How to find the place where the required page with id: 1 lies in this deeply nested structure? Run through the entire vault? Not the best solution.
Didn't find what you were looking for?
Ask your questionAsk a Question
731 491 924 answers to any question