# philistine

> Dead simple, minimally opinionated React library --- because SPA development isn't rocket science.

Latest version **0.0.3** (published 2018-04-17) · MIT license · 0 weekly downloads

## Install

```sh
npm install philistine
pnpm add philistine
yarn add philistine
bun add philistine
```

## Health

**Score 15/100 (F)** — status: abandoned.

Positive: no vulnerabilities.

Warnings: low downloads; no types; no esm support; pre 1.0.

Negative: abandoned; low maintenance score.

## Facts

| | |
|---|---|
| Version | 0.0.3 |
| Published | 2018-04-17 |
| First published | 2018-04-12 |
| Weekly downloads | 0 |
| License | MIT |
| TypeScript types | none |
| Module format | CommonJS |
| Dependencies | 6 |
| Unpacked size | 827.8 KB |
| Known vulnerabilities | 0 |
| Install scripts | no |
| GitHub stars | 1 |
| Author | Monarch Wadia |
| Maintainers | monarchwadia |

## Links

- npm: https://www.npmjs.com/package/philistine
- Repository: https://github.com/monarchjhaveri/jujutsu.js
- Homepage: https://github.com/monarchjhaveri/jujutsu.js#readme
- Issues: https://github.com/monarchjhaveri/jujutsu.js/issues
- npm.io page: https://npm.io/package/philistine

## Dependencies (6)

- [immer](https://npm.io/package/immer.md) ^1.2.1
- [commander](https://npm.io/package/commander.md) ^2.15.1
- [deepmerge](https://npm.io/package/deepmerge.md) ^2.1.0
- [react-router](https://npm.io/package/react-router.md) ^4.2.0
- [react-router-dom](https://npm.io/package/react-router-dom.md) ^4.2.2
- [immutability-helper](https://npm.io/package/immutability-helper.md) ^2.6.6

## Recent versions

- 0.0.3 (latest) — 2018-04-17
- 0.0.2 — 2018-04-17
- 0.0.1 — 2018-04-12

## README

# Philistine

Dead simple, minimally opinionated React library --- because SPA development isn't rocket science.

## Philosophy

Freedom is a very good thing. It works when it comes to governing nations. But the tradeoff is (as the saying goes) eternal vigilance. In other words, it introduces overhead and uncertainty. That cost is unnecessary in software projects whose requirements are well-defined and belong in software domains where most problems have already been solved. 

We assert that SPA development is one of these cases. Philistine aims to offer an opinionated framework for React that comes with batteries included.

## In progress

Philistine is an ideal. It isn't ready yet. Don't use it in production projects with dollar bills riding on it.

## Usage

### Installation

```
  npm install philistine
```

Note: `philistine` has peer depends on `react`, `react-dom` and `prop-types`. You will have to have these libraries installed on your project in order for `philistine` to function as expected.

### Construction

```
const initialState = { message: "Hello, World!" };
const phil = new Philistine(initialState);
phil.render(<YourRootComponent />, document.getElementById('your-main-div'));
```

### Accessing state

`phil.partial` contains an React component that takes a single callback as a child. That callback receives the entire state of the application.


You can use `phil.partial` at any depth in the application without passing props down in chains.

```
  <phil.partial>
    { ({message}) => message }
  </phil.partial>
```

Philistine uses React's `Context` API. The `partial` construct located at `new Philistine({}).partial` is nothing but a `Context.Consumer`. Please see [React's Context API](https://reactjs.org/docs/context.html) for more info.

### Updating State

Philistine has a single state that is accessible at all points in the application. 

Philistine uses React's [immutability-helper](https://reactjs.org/docs/update.html).  This is likely to change in the future, because `immutability-helper` introduces cumbersome syntax for very simple updates --- but it works for now.

To update state, you can call `phil.update` like this:

```
phil.update({message: { $set: 'Hello World!' }});
```

### Sample code

```
import Philistine, {partial} from 'philistine';
import React from 'react';
import ReactDom from 'react-dom';

class App extends React.Component {
  render() {
    return (
      <div>
        <phil.partial>
          { ({message}) => message }
        </phil.partial>
        <button onClick={() => phil.update({message: { $set: 'Hello World!' }})}>
          Click me
        </button>
      </div>
    )
  }
}

const initialState = {message: 'Not working yet!'};
const phil = new Philistine(initialState);
phil.render(<App />, document.getElementById('out'));
```

### Development

Make sure you run `npm run install-peers` to install various peerDependencies that Philistine needs during development.

---
_Source: https://npm.io/package/philistine · Machine-readable twin of the npm.io package page. Health data is recomputed on every publish._
