Ecosyste.ms: Awesome
An open API service indexing awesome lists of open source software.
https://github.com/laiff/react-fantasy
Rendering fantasyland structures in React
https://github.com/laiff/react-fantasy
Last synced: 26 days ago
JSON representation
Rendering fantasyland structures in React
- Host: GitHub
- URL: https://github.com/laiff/react-fantasy
- Owner: Laiff
- License: mit
- Created: 2014-12-12T16:52:32.000Z (almost 10 years ago)
- Default Branch: master
- Last Pushed: 2014-12-18T17:42:54.000Z (almost 10 years ago)
- Last Synced: 2024-10-09T09:10:38.062Z (28 days ago)
- Language: JavaScript
- Size: 188 KB
- Stars: 3
- Watchers: 2
- Forks: 0
- Open Issues: 0
-
Metadata Files:
- Readme: README.md
- License: LICENSE
Awesome Lists containing this project
README
react-fantasy
=============Rendering ```fantasyland``` structures in React.
## Options
Option is a container for value, witch encapsulate null check condition. Allow replace ```null``` with ```Option.None``` and write only logic without any checks.
Usage
```js
var React = require('react'),
Option = require('fantasy-options').Option,
option = require('react-fantasy').option;var SomeValue = React.createClass({
getDefaultProps : function () {
return {
value : Option.None;
}
},renderValue : function (value) {
return (
{value}
)
}render : function () {
return foldable(this.renderValue).exec(this.props.value);
}
});var SomeContainer = React.createClass({
getDefaultProps : function () {
return {
value : Option.of('Some string');
}
},render : function () {
return (
)
}
})```
Rendered as
```html
Some string
```## Type checkers
Add check propTypes and contextTypes for fantasy structures such as Option, Seq and Json. In future will be added Either, Readers, Writers and State
PropTypes example:
```js
var fpt = require('react-fantasy').PropTypes;var SomeClass = React.createClass({
...
propTypes : {
page: fpt.option.isRequired,
items: fpt.seq.isRequired,
config: fpt.json.isRequired
}
...
});
```Whenever non required values is possible, but that non functional behavior, because before rendering need some checks for ensure what value is present.
## License
MIT