Socket
Book a DemoInstallSign in
Socket

react-boxer

Package Overview
Dependencies
Maintainers
1
Versions
9
Alerts
File Explorer

Advanced tools

Socket logo

Install Socket

Detect and block malicious and high-risk dependencies

Install

react-boxer

Flex Box Manager of React

1.0.4
latest
Source
npmnpm
Version published
Weekly downloads
1
Maintainers
1
Weekly downloads
 
Created
Source

React-Boxer

React-Boxer supports a way to add(and remove) components flexiblely, this is pretty usefule for flexible projects.
You will use this if your project has float login panel, changed ads, popup dialogs and so on.

Install

npm install react-boxer --save-dev

Usage : Float Login Panel

Let's show a float login panel use case.

Float login panel will appear anywhere,anytime for an unlogin user, so it's hard to decide where to put it, and when to mount it.

  • First, we define a Login Component, with remove function.
    Login.js
import React, { Component } from 'react'
import { Boxer } from 'react-flex-router'

export default class Login extends Component {

  // remove login panel
  remove = ()=> {
    Boxer.remove(this)
  }

  render() {
    return (
      <div>
        <h5>Login</h5>
        <form>
          <div><input type='text' placeHolder={ this.props.defaultName ||'Username'} /></div>
          <div><input type='password' placeHolder='Password'/></div>
        </form>
        <div>

          <button onClick={ remove }>Cancel</button>

          <button>Login</button>
        </div>
      </div>
    )
  }
}
  • Second, we add a container to React (use Box)
    App.js
import React, { Component } from 'react'
import { Box } from 'react-boxer'
import User from './User'
// other import

class App extends Component {

  render() {
    return (
      <HashRouter>
        <div className='page-group'>
          <Route index path='/' component={ Home } />
          <Route path='/user' component={ User } />

          <Box index='1'/>

        </div>
      </HashRouter>
    )
  }
}
  • Now, you can add Login Component anywhere, anytime.
    User.js
import React, { Component } from 'react'
import { Boxer } from 'react-boxer'
import Login from './Login'

export default class User extends Component {

  // add login panel
  login = ()=> {
    Boxer.add(<Login defaultName={ 'John' } />, 1)
  }

  render() {
    return (
      <div>
        <button onClick={ this.login }>Login</button>
      </div>
    )
  }
}

Github

https://github.com/vifird/react-boxer

Contributors

git clone git@github.com:vifird/react-boxer.git

cd react-boxer

npm install

Keywords

react

FAQs

Package last updated on 18 Feb 2017

Did you know?

Socket

Socket for GitHub automatically highlights issues in each pull request and monitors the health of all your open source dependencies. Discover the contents of your packages and block harmful activity before you install or update your dependencies.

Install

Related posts

SocketSocket SOC 2 Logo

Product

About

Packages

Stay in touch

Get open source security insights delivered straight into your inbox.

  • Terms
  • Privacy
  • Security

Made with ⚡️ by Socket Inc

U.S. Patent No. 12,346,443 & 12,314,394. Other pending.