
Security News
vlt Launches "reproduce": A New Tool Challenging the Limits of Package Provenance
vlt's new "reproduce" tool verifies npm packages against their source code, outperforming traditional provenance adoption in the JavaScript ecosystem.
elegant-react
Advanced tools
Functional React Architecture inspired by omniscient and browser.html. Comments/suggestions/PRs are all welcome. This is still experimental.
This repo started off as a demonstration of some concepts that I wrote about in this Medium article and this one as well. However, since that time elegant-react has continued to evolve and things have changed significantly. For the purpose of education, you can check out the elegant-react-og repo which is a copy of the elegant-react repo immediately before it began to diverge from the content in those two Medium articles.
Install via npm
npm install elegant-react
Require it:
const {elegant, subedit} = require('elegant-react');
Or if you'd like to enable debug mode:
const {elegant, subedit} = require('elegant-react')({debug: true});
Require it:
const {elegant, subedit} = require('elegant-react/native');
Or if you'd like to enable debug mode:
const {elegant, subedit} = require('elegant-react/native')({debug: true});
Add the script:
//rawgit.com/gilbox/elegant-react/master/build/global/elegant-react.js
This exposes the global object ElegantReact
.
const {elegant, subedit} = ElegantReact;
Or if you'd like to enable debug
mode:
const {elegant, subedit} = ElegantReact({debug: true});
First, make sure you understand the subedit
function described in
this Medium article
Then add the @elegant
decorator to your component, specifying which
props are static.
const inc = n => n + 1;
@elegant({statics: ['editValue']})
class Item extends Component {
render() {
const {item,editValue} = this.props;
const onClick = _ => editValue(inc);
return <li onClick={ onClick }>
{ item.get('name') } - { item.get('value') }
</li>
}
}
Now put that component to use:
const reverse = data => data.reverse();
@elegant({statics: ['edit']})
class Items extends Component {
render() {
const {items,edit} = this.props;
const children = items.toArray().map(
(item, index) =>
<Item key={item.get('name')}
item={item}
editValue={sub(edit, index,'value')} /> );
return <div key="root">
<button onClick={_ => edit(reverse)}>reverse</button>
<ul>{ children }</ul>
</div>;
}
}
The rest of the source for this demo is here and you can see it in action as well.
You might notice that elegant-react has no dependencies
nor peerDependencies
listed in it's package.json file. This is so it can support both react and react-native
from the same npm package.
Clone this repo, then:
npm install
npm run examples
... and navigate to http://localhost:8080/webpack-dev-server/
statics
.lodash.isequal
,
elegant-react only performs shallow comparison assuming that if you need deep comparison
you will use immutable objects or define your own shouldComponentUpdate
This project was originally a simplified version of omniscient which promotes the functional approach of browser.html. However, it has since evolved to become a more unique thing of it's own (see differences from omniscient above)
FAQs
Elegant Functional Architecture for React
The npm package elegant-react receives a total of 2 weekly downloads. As such, elegant-react popularity was classified as not popular.
We found that elegant-react demonstrated a not healthy version release cadence and project activity because the last version was released a year ago. It has 1 open source maintainer collaborating on the project.
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.
Security News
vlt's new "reproduce" tool verifies npm packages against their source code, outperforming traditional provenance adoption in the JavaScript ecosystem.
Research
Security News
Socket researchers uncovered a malicious PyPI package exploiting Deezer’s API to enable coordinated music piracy through API abuse and C2 server control.
Research
The Socket Research Team discovered a malicious npm package, '@ton-wallet/create', stealing cryptocurrency wallet keys from developers and users in the TON ecosystem.