New Research: Supply Chain Attack on Axios Pulls Malicious Dependency from npm.Details
Socket
Book a DemoSign in
Socket

react-object-components

Package Overview
Dependencies
Maintainers
1
Versions
1
Alerts
File Explorer

Advanced tools

Socket logo

Install Socket

Detect and block malicious and high-risk dependencies

Install

react-object-components

latest
Source
npmnpm
Version
1.0.0
Version published
Maintainers
1
Created
Source

react-object-components

Just install the package:

npm i --save react-object-components

And wrap your component objects with roc:

import roc from 'react-object-components'

const App = roc({
  data: () => ({
    count: 0,
    timer: null
  }),

  mounted() {
    this.timer = setInterval(function() {
      this.increment()
    }.bind(this), 1000)
  },

  unmount() {
    clearInterval(this.timer)
  },

  methods: {
    increment() {
      this.count = this.count + 1
    },
  },

  render() {
    return (
      <>
        {this.count}
        <Button onClick={() => this.count = this.count + 1}>inc</Button>
        <Button onClick={() => this.count = this.count - 1}>dec</Button>
      </>
    )
  }
})

const Button = roc({
  rerender(nextProps, nextState) {
    return false
  },

  render() {
    console.log("render")
    return (
      <button onClick={this.props.onClick}>{this.props.children}</button>
    )
  }
})

ReactDOM.render(
  <React.StrictMode>
    <App />
  </React.StrictMode>,
  document.getElementById('root')
)

Keywords

react

FAQs

Package last updated on 15 Nov 2021

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