Skip to content

Commit

Permalink
feat: update react and drop support for react dev tools
Browse files Browse the repository at this point in the history
  • Loading branch information
macoley committed Jan 12, 2023
1 parent 084ace7 commit 8e78aea
Show file tree
Hide file tree
Showing 12 changed files with 778 additions and 2,390 deletions.
15 changes: 0 additions & 15 deletions README.md
Original file line number Diff line number Diff line change
Expand Up @@ -20,7 +20,6 @@ npm i @bit-about/state
- ...or utilise static access
- No centralized state provider
- Tiny - only **1.4kB**
- Redux DevTools support
- **Just works**

### ➡️ [Check demo](https://bit-about.github.io/state/)
Expand Down Expand Up @@ -145,20 +144,6 @@ const [Provider, useStore] = state(
)
```

## Redux DevTools support
<details>
<summary>Presentation</summary>

https://user-images.githubusercontent.com/1496580/167521849-5529a981-31f6-47d5-8830-054018734f00.mov
</details>

To help work with DevTools two hooks helpers have been introduced:
- [`useSideEffect`](https://github.com/bit-about/state/wiki/Redux-DevTools#recording-side-effects) to make state change expected and followable in dev tools
- [`useStoreName`](https://github.com/bit-about/state/wiki/Redux-DevTools#giving-a-name-to-store) to give a name inspected store

[How to use Redux DevTools](https://github.com/bit-about/state/wiki/Redux-DevTools)


## BitAboutState 💛 [BitAboutEvent](https://github.com/bit-about/event)

Are you tired of sending logic to the related components?<br />
Expand Down
48 changes: 23 additions & 25 deletions example/package-lock.json

Some generated files are not rendered by default. Learn more about how customized files appear on GitHub.

1 change: 0 additions & 1 deletion example/src/components/App/App.jsx
Original file line number Diff line number Diff line change
Expand Up @@ -47,7 +47,6 @@ function App() {
</header>
<Demo />
</div>
<p className='footer'>🎉 Redux DevTools works on this page</p>
</div>
)
}
Expand Down
10 changes: 3 additions & 7 deletions example/src/components/Demo/Demo.jsx
Original file line number Diff line number Diff line change
@@ -1,7 +1,8 @@
import { useState, useRef, useEffect } from 'react'
import { state, useStoreName, useSideEffect } from '@bit-about/state'
import { state } from '@bit-about/state'
import { SwitchTransition, CSSTransition } from 'react-transition-group'
import './Demo.css'
import { useCallback } from 'react'

/**
* Extracted code from @bit-about/state store creator
Expand All @@ -15,10 +16,7 @@ import './Demo.css'
function useAutoIncrementJohn() {
const [autoIncrementJohn, setAutoIncrementJohn] = useState(0)

const incrementJohn = useSideEffect(
() => setAutoIncrementJohn((value) => value + 1),
'autoIncrementJohn'
)
const incrementJohn = useCallback(() => setAutoIncrementJohn((value) => value + 1), [setAutoIncrementJohn])

useEffect(() => {
const interval = setInterval(incrementJohn, 5000)
Expand All @@ -32,8 +30,6 @@ function useAutoIncrementJohn() {
* @bit-about/state
*/
const [StoreProvider, useStore] = state(({ alice: initialAlice }) => {
useStoreName('MyCustomStore')

const [alice, setAlice] = useState(initialAlice)
const [bob, setBob] = useState(0)

Expand Down
Loading

0 comments on commit 8e78aea

Please sign in to comment.