1.0.0 • Published 7 years ago

react-native-reactify v1.0.0

Weekly downloads
2
License
ISC
Repository
github
Last release
7 years ago

Reactify

Create React Native interfaces using JSON format.

Install

npm install react-native-reactify --save

Usage

import React from 'react';
import {View, Button, Alert} from 'react-native';
import reactify from 'react-native-reactify';

/**
 * It will be executed when the "Hello" button is pressed.
 *
 * @param {Event} e
 */
function onPress(e) {
  Alert.alert('World');
}

/**
 * Object description of a React component.
 */
const helloWorld = {
  type: 'View',
  style: {
    flex: 1,
    alignItems: 'center',
    justifyContent: 'center',
    backgroundColor: '#eff'
  },
  children: {
    type: 'Button',
    title: 'Hello',
    onPress,
    style: {
      fontSize: 40,
      color: '#444'
    }
  }
};

export default class App extends React.Component {
  render() {
    return reactify(helloWorld, {View, Button});
  }
}