Socket
Book a DemoInstallSign in
Socket

cellx-react

Package Overview
Dependencies
Maintainers
1
Versions
5
Alerts
File Explorer

Advanced tools

Socket logo

Install Socket

Detect and block malicious and high-risk dependencies

Install

cellx-react

cellx-react ===========

1.10.2
latest
Source
npmnpm
Version published
Weekly downloads
0
-100%
Maintainers
1
Weekly downloads
 
Created
Source

cellx-react

Install

npm install cellx cellx-decorators react react-dom cellx-react --save

More about cellx-decorators: cellx-decorators.

Example

import { Observable, Computed } from 'cellx-decorators';
import React from 'react';
import ReactDOM from 'react-dom';
import { Observer } from 'cellx-react';

class User {
	@Observable name = void 0;
	@Observable birthdate = void 0;

	@Computed
	get age() {
		return birthdateToAge(this.birthdate);
	}

	constructor(name, birthdate) {
		this.name = name;
		this.birthdate = birthdate;
	}
}

let user = new User('Матроскин', '05/03/2006');

@Observer
class UserCard extends React.Component {
	@Computed
	get ageLess18() {
		return user.age < 18;
	}

	render() {
		return (
			<p>
				Привет, {user.name}!
				{` Вам ${ this.ageLess18 ? 'ещё нет' : 'уже есть' } 18 лет (вам ${ user.age }).`}
			</p>
		);
	}
}

ReactDOM.render(
	<UserCard/>,
	document.getElementById('example')
);

// Вычисляет возраст по дате рождения.
function birthdateToAge(birthdate) {
	birthdate = new Date(birthdate);
	let now = new Date();
	let age = now.getFullYear() - birthdate.getFullYear();
	return now.setFullYear(1972) < birthdate.setFullYear(1972) ? age - 1 : age;
}

FAQs

Package last updated on 05 Jun 2020

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.