Babel is used by millions, so why are we running out of money? (2021)
babeljs.io89 pointsby dmitriid125 comments
// redux
import { useSelector, useDispatch } from 'react-redux'
import { decrement, increment } from './counterSlice'
export function Counter() {
// note how we reach into magical global state that useSelector knows about
const count = useSelector((state: RootState) => state.counter.value)
const dispatch = useDispatch()
return <>
<button => dispatch(increment())}>Increment</button>
<span>{count}</span>
<button => dispatch(decrement())}>Decrement</button>
</>;
}
// solid
// state is immutable. It's also not magical, you explicitly refrence and import it
//
// increment and decrement would use a `set` function to update the store to required value
// see https://www.solidjs.com/docs/latest/api#createstore
// and https://www.solidjs.com/docs/latest/api#updating-stores
//
import { state, increment, decrement } from './counter-store';
export function Counter() {
return <>
<button => increment()}>Increment</button>
<span>{state.count}</span>
<button => decrement()}>Decrement</button>
</>;
}