0.0.1-security • Published 2 years ago

wherehouse v0.0.1-security

Weekly downloads
5
License
-
Repository
-
Last release
2 years ago

Wherehouse

Redux sucks.

So I made a lightweight global state management solution using react hooks.

Should not be used by anyone except myself.

Install

$ npm i wherehouse

Usage

App.js

import React from 'react';
import { init, setData } from 'wherehouse';
import User from './components/User';

// Initialize the store
init({
	NAME: 'Alice',
	AGE: 18,
});

function App() {
	// Update a data from the store
	// While this updates, the `age` in `User` component also updates
	const addAge = () => setData('AGE', age => age + 1);

	return (
		<div className="app">
			<User />
			<button onClick={addAge}>Age+1</button>
		</div>
	);
}

export default App;

User.js

import React from 'react';

import { useData } from 'wherehouse';

const User = () => { // Use data from store const name = useData('NAME'); const age = useData('AGE');

return (
	<div>
		<h2>Name: {name}</h2>
		<h2>Age: {age}</h2>
	</div>
);

}

export default User;

0.0.1-security

2 years ago

1.3.2

2 years ago

1.3.1

2 years ago

1.3.0

2 years ago

1.2.1

2 years ago

1.1.2

2 years ago

1.2.0

3 years ago

1.1.1

3 years ago

1.1.0

3 years ago

1.0.3

4 years ago

1.0.2

4 years ago

1.0.1

4 years ago

0.0.1

4 years ago

1.0.0

4 years ago