Comments (7)
Can you provide some more code for me to understand. And which version are you using?
from normalizr-immutable.
Sorry, I move from normalizr-immutable
to vanilla Immutable.fromJS
for better handleability.
But there is commit of this issue
I think origin of this issue is that initialState of project reducer is Map({}) there
import { Map } from "immutable"
import * as types from "../projectConstants"
const initialState = Map({})
export default function projects(state = initialState, action = {}) {
switch (action.type) {
case types.LOAD_PROJECTS: {
return state.merge(action.payload)
}
default:
return state
}
}
And then I merge it like this dispatch(loadProjects(normalized.entities.projects))
And when I try use it state.projects.toString()
, it throw Cannot read property 'entities' of undefined
error
from normalizr-immutable.
Ok, at a glance, it seems to me that you should merge entities and not entities.projects.
Also, "property 'entitities' of undefined" suggests that the projectsReducer is not available when that call is made. This could be related to not supplying the reducer reference correctly in the schema definition.
My personal preference is to make the state a Record instead of a Map. I think it's more elegant since it kind of defines an API.
I would define it for instance as
const ProjectState = Record({
entities: Map(),
result: OrderedSet()
})
const initialState = new ProjectState();
from normalizr-immutable.
Yes, or I had to use NormalizedRecord as initialState, I just surprised that entities created by "normalizr-immutable" is not compatible with vanilla immutable entities at first glance, I will close the issue, thanks you for your time
P.S. I thought that Record doesn`t have Iterable methods, I was misguided by official documentation 😄
from normalizr-immutable.
The entities created by normalizr-immutable are simple immutable Records, fully compatible. If you start using the Proxy facilities, you have to take a little more care in how you use things. But for me, the pains are worth it.
One more thing: I recommed using the latest 0.0.4 beta of normalize-immutable. Depending on configuration the 0.0.3 branch uses a Record for the entities structure which was a misguided choice on my part.
from normalizr-immutable.
Ok, currently I just teaching react, it seems I will return to normalizr-immutable
once)
from normalizr-immutable.
OK, I returned to normalizr-immutable
, and find out that Records dont have useful Iterable methods (map/filter, just as I say, actually they have them, but they return undefined
and will show warnings in future versions, spent plenty of time on that), so I better use Maps
And because there more cozy way to immutate initial state with vanilla fromJS
(is that so?), I move to that
from normalizr-immutable.
Related Issues (14)
- Support deep merge of different normalizr entities HOT 3
- Late binding: ignoring the proxies in certain cases
- "A record is required" error is thrown
- Proper way to merge entities HOT 1
- Compatibility with transit-immutable-js HOT 1
- 0.0.4 release wish HOT 3
- [SEO] 'normalizr-immutable' package leads to Googlebot rendering blank page on webmasters page
- Unable to import from 'normalizr-immutable' HOT 3
- Unnecessary overhead from harmony-reflect HOT 1
- reducer key per schema? HOT 8
- Map/Record is preferred when object key is referenced HOT 5
- How to handle merge entity records into NormalizedRecord? HOT 5
- hydrating client stores from server + proxies HOT 2
Recommend Projects
-
React
A declarative, efficient, and flexible JavaScript library for building user interfaces.
-
Vue.js
🖖 Vue.js is a progressive, incrementally-adoptable JavaScript framework for building UI on the web.
-
Typescript
TypeScript is a superset of JavaScript that compiles to clean JavaScript output.
-
TensorFlow
An Open Source Machine Learning Framework for Everyone
-
Django
The Web framework for perfectionists with deadlines.
-
Laravel
A PHP framework for web artisans
-
D3
Bring data to life with SVG, Canvas and HTML. 📊📈🎉
-
Recommend Topics
-
javascript
JavaScript (JS) is a lightweight interpreted programming language with first-class functions.
-
web
Some thing interesting about web. New door for the world.
-
server
A server is a program made to process requests and deliver data to clients.
-
Machine learning
Machine learning is a way of modeling and interpreting data that allows a piece of software to respond intelligently.
-
Visualization
Some thing interesting about visualization, use data art
-
Game
Some thing interesting about game, make everyone happy.
Recommend Org
-
Facebook
We are working to build community through open source technology. NB: members must have two-factor auth.
-
Microsoft
Open source projects and samples from Microsoft.
-
Google
Google ❤️ Open Source for everyone.
-
Alibaba
Alibaba Open Source for everyone
-
D3
Data-Driven Documents codes.
-
Tencent
China tencent open source team.
from normalizr-immutable.