5.9.5 • Published 5 months ago

creeks v5.9.5

Weekly downloads
-
License
MIT
Repository
github
Last release
5 months ago

Creeks

React global state management "Easy and Fast"

Validator

NPM JavaScript Style Guide

Basic demo: codesandbox

Advanced demo: codesandbox

Install

npm install --save creeks

Basic usage

store.js
import createState from 'creeks'

const store = {

    username: createState()
}

export default store
ChildA.js
import React from 'react'
import { useCopy } from 'creeks'
import store from './store'

const ChildA = () => {

    /**
     * Username Global state
     */
    const [username] = useCopy(store.username)

    return <p>Im "ChildA" and your username is {username}</p>
}

export default ChildA
ChildB.js
import React from 'react'
import { useCopy } from 'creeks'
import store from './store'

const ChildB = () => {

    /**
     * Username Global state
     */
    const [username] = useCopy(store.username)

    return <p>Im "ChildB" and your username is {username}</p>
}

export default ChildB
Control.js
import React from 'react'
import store from './store'

const Control = () => {

    return <button onClick={() => store.username.update('CreeksDev')}>Set username</button>
}

export default Control
index.js
import React from 'react'
import { createRoot } from 'react-dom/client'
import ChildA from './ChildA'
import ChildB from './ChildB'
import Control from './Control'


const App = () => {

    return (
        <React.Fragment>
            <ChildA />
            <hr />
            <ChildB />
            <hr />
            <Control />
        </React.Fragment>
    )
}

const container = document.getElementById('root');
const root = createRoot(container);
root.render(<App />);

Important

If you update to "React 18" Make sure to make these changes in the index.js file
// Before
import { render } from 'react-dom';
const container = document.getElementById('app');
render(<App tab="home" />, container);

// After
import { createRoot } from 'react-dom/client';
const container = document.getElementById('app');
const root = createRoot(container); // createRoot(container!) if you use TypeScript
root.render(<App tab="home" />);

know more: https://reactjs.org/blog/2022/03/08/react-18-upgrade-guide.html

License

MIT © zohayrslileh

5.6.0

9 months ago

5.4.0

9 months ago

5.3.0

9 months ago

5.2.0

9 months ago

5.1.0

9 months ago

4.9.0

9 months ago

4.8.0

9 months ago

4.5.0

9 months ago

4.2.2

9 months ago

4.7.0

9 months ago

4.6.0

9 months ago

4.3.0

9 months ago

5.9.5

5 months ago

5.9.4

5 months ago

5.9.3

6 months ago

5.9.2

7 months ago

5.9.0

7 months ago

5.8.0

8 months ago

5.7.0

9 months ago

4.1.2

2 years ago

4.1.1

2 years ago

4.1.0

2 years ago

4.0.0

2 years ago

3.7.3

2 years ago

3.7.2

2 years ago

3.7.1

2 years ago

3.6.5

2 years ago

3.6.4

2 years ago

3.6.3

2 years ago

3.6.2

2 years ago

3.6.1

2 years ago

3.5.2

2 years ago

3.5.1

2 years ago

3.4.4

2 years ago

3.4.3

2 years ago

3.4.2

2 years ago

3.4.1

2 years ago

3.4.0

2 years ago

3.2.0

2 years ago

3.0.0

2 years ago

2.0.0

2 years ago

1.0.0

2 years ago