
Security News
Feross on TBPN: How North Korea Hijacked Axios
Socket CEO Feross Aboukhadijeh breaks down how North Korea hijacked Axios and what it means for the future of software supply chain security.
Hyperwrap embodies the principles of hyperapp and transfers them to react, turning react into a simple to use functional framework.
The easiest way to get going is to install the seed project using douglas.
douglas installs npm modules as ready to roll projects...
If you don't have douglas, install globally with npm i -g douglas
Install hyperwrapped-react (seed project)
douglas get hyperwrapped-react
If you haven't used parcel-bundler before, then install globally with
npm i -g parcel-bundler... then ...
npm start
A typical entry index.tsx looks like...
import { app } from "hyperwrap";
import { initialState } from "./src/state/state";
import { View } from "./src/components/view/view.component";
app(initialState, View, document.getElementById('app'));
initialState is just a plain js object.
View is just a plain React functional component
getState() gets global state and updateState() updates it...
import * as React from 'react';
import { State } from '../../../state/state';
import { getState, updateState } from 'hyperwrap';
interface Props {
state?: State;
}
export const Home = () => {
const changeThing = (e: any, thing: string) => { updateState('thing', thing); };
return (
<div>
<p>{getState().thing}</p>
<button onClick={(e) => {changeThing(e, 'bob')} }>push</button>
</div>
);
};
In order to make the above pure and testable, we optionally allow state to be injected. By default state is set to getState()...
import * as React from 'react';
import { State } from '../../../state/state';
import { getState, updateState } from 'hyperwrap';
interface Props {
state?: State;
}
const props = {
state: getState()
}
export const Home = ({state}: Props = props) => {
const _state = state || props.state;
const changeThing = (e: any, thing: string) => { updateState('thing', thing); };
return (
<div>
<p>{_state.thing}</p>
<button onClick={(e) => {changeThing(e, 'bob')} }>push</button>
</div>
);
};
Note the use of _state. We do this because typescript thinks that state may be undefined.
const _state = state || props.stateensures that _state is definately not undefined.
To update state, specify the node in the state object to update, followed by the value.
updateState('deep/nested/thing', newValue);
Adding nodes - Use the above. If parent nodes aren't created yet, they will be created for you.
Deleting nodes - Make the newValue undefined. Any parent node clean up will also be taken care of.
Actions are just functions in hyperwrap.
Treat them sensibly (make them DRY, stored in a sensible place, and import as necessary).
Below we've moved changeThing out to it's own module.
We import it and inject it into the props (like state).
This makes it pure and easy to test...
import * as React from 'react';
import { State } from '../../../state/state';
import { Actions } from '../../../actions/actions';
import { getState } from 'hyperwrap';
import { changeThing } from './change-thing.function';
interface Props {
state?: State;
actions?: Actions;
}
const props = {
state: getState(),
actions: {
changeThing
}
}
export const Home = ({state, actions}: Props = props) => {
const _state = state || props.state;
const _actions = actions || props.actions;
return (
<div>
<p>{_state.thing}</p>
<button onClick={(e) => {_actions.changeThing(e, 'bob')} }>push</button>
</div>
);
};
FAQs
Makes React simple and functional
The npm package hyperwrap receives a total of 1 weekly downloads. As such, hyperwrap popularity was classified as not popular.
We found that hyperwrap 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
Socket CEO Feross Aboukhadijeh breaks down how North Korea hijacked Axios and what it means for the future of software supply chain security.

Security News
OpenSSF has issued a high-severity advisory warning open source developers of an active Slack-based campaign using impersonation to deliver malware.

Research
/Security News
Malicious packages published to npm, PyPI, Go Modules, crates.io, and Packagist impersonate developer tooling to fetch staged malware, steal credentials and wallets, and enable remote access.