hrx

Overview
Framework for React and Formula.
why hrx?
- h is for hyperscript.
- r is for
RUN
expression. - x is for xander.
hrx is hyperscript + formula + xander
Usage
Installation
npm install --save hrx formula
Examples
Quick start
A minimal hrx app with home and 404 page.
import { render } from "hrx";
let routes = [
{
path: "/",
component: props => "Hello, World."
},
{
path: "*",
component: props => "No Page Found"
}
];
render({ routes }, document.getElementById("root"));
With React's render
Render HRX with React's render function.
import { app } from "hrx";
import React from "react";
import { render } from "react-dom";
let routes = [# hrx
[);
With React's render
Render HRX with React's render function.
import { app } from "hrx";
import React from "react";
import { render } from "react-dom";
let routes = [
{
path: "/",
component: props => "Hello, World."
},
{
path: "*",
component: props => "No Page Found"
}
];
let App = app({ routes });
render(<App />, document.getElementById("root"));
Components
Link Component
A link component to hyperlink your app without annoying page refreshes.
import {Link} from 'hrx'
<Link to="/buckets" />
<Link type="button" to="/buckets" />
<Link type="button" to="/buckets" type="button" />
Eval Component
The Eval component calculates the result of a formula expression.
import {Eval} from 'hrx'
<Eval exp="SUM(A, B)" values={ A: 2, B: 2 } />
Rule Component
The Rule component renders HTML describing a formula expression.
import {Rule} from 'hrx'
<Rule exp="SUM(A, B)" />
Container Component
The Container component renders a child component based on URL.
import { Link } from "hrx";
render(<Container />);
Connect Component
The Connect HOC component syncs Xander state with React state.
import { connect, Container } from "hrx";
render(
connect(Container)
);
Loadable / loader HOCs
The Loadable HOC works with webpack to split your app into chunks that load dynamically.
import { loadable, loader } from "hrx";
let routes = [
{
path: "/",
component: loadable({
loader: () => import("./home"),
delay: 500
})
},
{
path: "*",
component: loader(() => import("./404"))
}
];
Stores
Router
A minimal router, backed by native history API.
import { router } from "hrx";
router.open("/buckets/1");
Use redirect
to modify URL without adding an entry to the history state.
router.redirect("/buckets");
Load Routes
Load routes and related configuration without boot
.
import { router } from "hrx";
router.loadRoutes([
{
path: "/",
component: require("./pages/home")
}
]);
Window Store
The window store (optional) keeps track of window size and scroll location; keeps in sync with DOM.
import { loadWindowStore } from "hrx";
loadWindowStore();
Custom State management
Use createStore
to manage locally cached data.
import { createStore } from "hrx";# hrx
[);
With React's render
Render HRX with React's render function.
import { app } from "hrx";
import React from "react";
import { render } from "react-dom";
let routes = [
{
path: "/",
component: props => "Hello, World."
},
{
path: "*",
component: props => "No Page Found"
}
];
let App = app({ routes });
render(<App />, document.getElementById("root"));
Components
Link Component
A link component to hyperlink your app without annoying page refreshes.
import {Link} from 'hrx'
<Link to="/buckets" />
<Link type="button" to="/buckets" />
<Link type="button" to="/buckets" type="button" />
Eval Component
The Eval component calculates the result of a formula expression.
import {Eval} from 'hrx'
<Eval exp="SUM(A, B)" values={ A: 2, B: 2 } />
Rule Component
The Rule component renders HTML describing a formula expression.
import {Rule} from 'hrx'
<Rule exp="SUM(A, B)" />
Container Component
The Container component renders a child component based on URL.
import { Link } from "hrx";
render(<Container />);
Connect Component
The Connect HOC component syncs Xander state with React state.
import { connect, Container } from "hrx";
render(
connect(Container)
);
Loadable / loader HOCs
The Loadable HOC works with webpack to split your app into chunks that load dynamically.
import { loadable, loader } from "hrx";
let routes = [
{
path: "/",
component: loadable({
loader: () => import("./home"),
delay: 500
})
},
{
path: "*",
component: loader(() => import("./404"))
}
];
Stores
Router
A minimal router, backed by native history API.
import { router } from "hrx";
router.open("/buckets/1");
Use redirect
to modify URL without adding an entry to the history state.
router.redirect("/buckets");
Load Routes
Load routes and related configuration without boot
.
import { router } from "hrx";
router.loadRoutes([
{
path: "/",
component: require("./pages/home")
}
]);
Window Store
The window store (optional) keeps track of window size and scroll location; keeps in sync with DOM.
import { loadWindowStore } from "hrx";
loadWindowStore();
Custom State management
Use createStore
to manage locally cached data.
import { createStore } from "hrx";
createStore(name, reducerOrSpec, actionsAndQueries);
For more info checkout xander.