0.0.2 • Published 8 years ago
modx v0.0.2
modx v2.1.0
Model-backed components for React Native
npm install modx --save
Component.Type
Every model-backed component relies on the Component.Type
constructor.
It assists in building the factory that creates both your models and their component instances.
{Component} = require "modx"
type = Component.Type "Foo"
Note: Naming the type is optional.
The first thing every component model needs is a render
method.
type.render ->
# TODO: Create and return a `ReactElement`.
return false # <= Render nothing for now.
Before we learn anything else, let's finalize our model factory so we can try the render
method.
# Finalize the model factory.
Foo = type.build()
# Initialize a model instance.
foo = Foo()
foo.render() # => false
Using model-backed components means you can:
Re-render without using
setState
Avoid the
ref
callback (you already have the model, which has access to its view)And more... (which I'll add here at a later date)