Skip to content

Instantly share code, notes, and snippets.

View useRefState useStateWithRef
const useStateWithRef = (initialState) => {
const [state, _setState] = React.useState(initialState);
const ref = React.useRef(state);
const setState = React.useCallback(
(newState) => {
if (typeof newState === 'function') {
_setState(prevState => {
const computedState = newState(prevState);
ref.current = computedState;
return computedState;
View composer.json.example.forpsr4
{
"name": "Myapp/Myapp",
"description": "",
"keywords": ["secret"],
"require": {
"php": ">=5.5.0",
"slim/slim": "3.0",
"slim/php-view": "^2.0",
"monolog/monolog": "^1.17",
"wepay/php-sdk": "^0.2",
You can’t perform that action at this time.