1.1.4 • Published 5 years ago

redux-for-noobs v1.1.4

Weekly downloads
3
License
ISC
Repository
github
Last release
5 years ago

redux-for-noobs

A simplified store thing written by a noob for noobs.

Install

npm i redux-for-noobs

Usage

Store.jsx

import React from 'react'
import { Provider, simpleStore, OPTIONS } from 'redux-for-noobs'

const store = simpleStore({
  testCount: 0,
  something: false,
  else: {}
}, [ 
  OPTIONS.STRICT_TYPES, // optional - forces any changes to `testCount` to be the type of the default value set
  OPTIONS.STRICT_NAMING // optional - removes anything that is not `A-z_-` from store names
])

const Store = ({ children }) => (
	<Provider store={store}>
		{children}
	</Provider>
)

export default Store

ExampleView.jsx

import React from 'react'
import Store from './Store'

import { useStore } from 'redux-for-noobs'


const ExampleView = () => {

	const { testCount, setTestCount } = useStore()

	return (
        <Store>
            count is {testCount}
  
			<button onClick={() => setTestCount(testCount + 1)}>
				increment testCount by 1
			</button>
		</Store>
	)
}

export default ExampleView

Profit

No more reducers and no more actions, just set and go!

Not actually sure if this is useful in anyway or effective, but I like it...

1.1.4

5 years ago

1.1.3

5 years ago

1.1.2

5 years ago

1.1.1

5 years ago

1.1.0

5 years ago

1.0.4

5 years ago

1.0.3

5 years ago

1.0.2

6 years ago

1.0.1

6 years ago