Coder Social home page Coder Social logo

react-region's Introduction

React Region

Description

React Region component lets you mount components by passing plain objects to its region prop.

Why

Useful for automating components using plain objects.

Installation

npm i --save react-region

Demo

npm start dev then visit http://127.0.0.1:3000

Usage

import { makeRegion } from 'react-region';
import Example from './Example';

// Configure which components can be mounted in regions.
const Region = makeRegion({
  Example
});

// In real world these data would come from e.g. a JSON file. Careful with XSS
// if you do that over the network.
const region = [{
  type: 'Example',
  props: {
    key: 'some-example',
    test: 'This is an example component',
    className: 'some-class',
    children: [
      //...
    ]
  }
}];

<Region region={ region }/>

With arbitrary data

<Region id='wrapper' className='wrapper'>
  { state => (
    <div className={ 'some-class ' + (state && state.className ? state.className : '') }>
      hello <span style={ state && state.style ? state.style : null }>world</span>
    </div>
  ) }
</Region>

react-region's People

Contributors

akofman avatar jide avatar

Watchers

 avatar  avatar

Recommend Projects

  • React photo React

    A declarative, efficient, and flexible JavaScript library for building user interfaces.

  • Vue.js photo Vue.js

    ๐Ÿ–– Vue.js is a progressive, incrementally-adoptable JavaScript framework for building UI on the web.

  • Typescript photo Typescript

    TypeScript is a superset of JavaScript that compiles to clean JavaScript output.

  • TensorFlow photo TensorFlow

    An Open Source Machine Learning Framework for Everyone

  • Django photo Django

    The Web framework for perfectionists with deadlines.

  • D3 photo 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.

  • Game

    Some thing interesting about game, make everyone happy.

Recommend Org

  • Facebook photo Facebook

    We are working to build community through open source technology. NB: members must have two-factor auth.

  • Microsoft photo Microsoft

    Open source projects and samples from Microsoft.

  • Google photo Google

    Google โค๏ธ Open Source for everyone.

  • D3 photo D3

    Data-Driven Documents codes.