modelizr
modelizr copied to clipboard
Unable to use the normalize function independently
Is the normalize function available globally? What if I need to normalize something that is not being fetched via an API ?
It does not work when I import the normalizr package to my project and use that function with the modelizr schema
Modelizr schema's aren't compatible with Normalizr. Unfortunately Modelizr doesn't currently expose a way to normalize data outside of api calls.
It would be a good addition though and I'd be happy to add. A quick hack for the interim would be to do something like:
import normalize from "modelizr/lib/data/normalization"
normalize({
data: <Object>,
modelFunctions: <ModelizrSchema>,
clientState: <ClientState>
})
Where data
is the data you want to normalize, modelFunctions
is your modelizr schema and clientState
is a property from a Modelizr instance - i.e new Modelizr().clientState
.
Let me know if that works for you
Thank you.