Skip to content

usePrevious hook #17

@Ruben-Arushanyan

Description

@Ruben-Arushanyan
import {useEffect, useRef} from 'react';

const usePrevious = (value) => {
    const ref = useRef();
    useEffect(() => {
        ref.current = value;
    });
    return ref.current;
};

export {usePrevious};

Metadata

Metadata

Labels

Projects

No projects

Milestone

No milestone

Relationships

None yet

Development

No branches or pull requests

Issue actions