Socket
Socket
Sign inDemoInstall

create-react-class

Package Overview
Dependencies
3
Maintainers
5
Versions
19
Alerts
File Explorer

Advanced tools

Install Socket

Detect and block malicious and high-risk dependencies

Install

    create-react-class

Legacy API for creating React components.


Version published
Weekly downloads
1.4M
decreased by-19.41%
Maintainers
5
Install size
111 kB
Created
Weekly downloads
 

Package description

What is create-react-class?

The create-react-class package is a utility that allows you to write React components using a syntax similar to ES5, which is useful for those who are not using ES6 classes. It was extracted from the main React library when classes were introduced in ES6 to provide backward compatibility for older codebases or for those who prefer not to use ES6 syntax.

What are create-react-class's main functionalities?

Creating React components

This feature allows you to create React components using an ES5 syntax. The example shows a simple component that renders a greeting message.

var createReactClass = require('create-react-class');
var Greeting = createReactClass({
  render: function() {
    return <h1>Hello, {this.props.name}</h1>;
  }
});

Specifying propTypes and defaultProps

This feature allows you to specify propTypes and defaultProps for your component, which helps with type checking and setting default values for props.

var createReactClass = require('create-react-class');
var Greeting = createReactClass({
  propTypes: {
    name: PropTypes.string
  },
  getDefaultProps: function() {
    return {
      name: 'World'
    };
  },
  render: function() {
    return <h1>Hello, {this.props.name}</h1>;
  }
});

Using lifecycle methods

This feature allows you to use lifecycle methods such as componentDidMount, which can be used for operations that need to happen after the component is inserted into the DOM.

var createReactClass = require('create-react-class');
var Greeting = createReactClass({
  componentDidMount: function() {
    console.log('Component did mount!');
  },
  render: function() {
    return <h1>Hello, {this.props.name}</h1>;
  }
});

Other packages similar to create-react-class

Changelog

Source

15.7.0 (October 14, 2020)

React

  • Backport support for the new JSX transform to 15.x. (@lunaruan in #18299 and @gaearon in #20024)

Readme

Source

create-react-class

A drop-in replacement for React.createClass.

Refer to the React documentation for more information.

Keywords

FAQs

Last updated on 15 Oct 2020

Did you know?

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

  • Package Alerts
  • Integrations
  • Docs
  • Pricing
  • FAQ
  • Roadmap

Stay in touch

Get open source security insights delivered straight into your inbox.


  • Terms
  • Privacy
  • Security

Made with ⚡️ by Socket Inc