Egor Blinov
Egor Blinov
You could probably do something like this ```js const [count, setCount] = useState(0); const countRef = useRef(count) useEffect(() => { countRef.current = count }, [count]) useEffect(() => { // send...
@liyuanqiu I see such options: - use ref for holding the whole callback rather then single state - create custom `useStateWithRef()` hook which could decorate the original `useState` and mirror...
@btraljic yeah, i suggested the same thing >```js >function useStateWithRef(initial) { > const [state, setState] = useState(initial) > const ref = useRef() > ref.current = state > return [state, setState,...
@btraljic not really :) now you have actual value in reference and can use it in next effects, but if once you decide to use it in markup, you would...
Speaking about accessing state in `setInterval` — i came up with another idea. It can be treated as two separate side effects: one is timer tick, another is `xhr`. So...
Doing so, you can't use more than one `Comp` on the page, but it could be fixed ```js function CompFabric () { const obj = {} return function Comp() {...
Sure, it looks familiar. The only difference with hooks here is that component's `state` is explicitly bounded to instance and so could be accessed with `this` anywhere. To achieve the...
I guess this is it https://overreacted.io/making-setinterval-declarative-with-react-hooks/ :)
The root of the problem are the following 3 pieces of code: 1) subscription to location change in `connected-react-router` + subsequent dispatch and update of all connected components https://github.com/supasate/connected-react-router/blob/a1053804b1097cda52e14b4e52b5a0ea3a421ede/src/ConnectedRouter.js#L72 2)...
@salvoravida what do you mean here > the MAIN problem of connect-react-router, is that it depends on react-component lifecycle `connected-react-router` only subscribe to history in it’s `constructor` and that’s all....