inertia
inertia copied to clipboard
Multiple useRemember() not working as expected
Version:
@inertiajs/reactversion: 1.2.0
Describe the problem:
Multiple useRemember() calls in the same component produce unreliable results. The value being remembered is only the last one. I believe it's by design, but it would be much more convenient to use it like useState(), where we'd keep each value separate instead of packing them all together.
Steps to reproduce:
Try this page:
import React from 'react';
import { useRemember } from '@inertiajs/react';
export default function () {
const [foo, setFoo] = useRemember(1);
const [bar, setBar] = useRemember(2);
return (
<>
{foo} {bar}
</>
);
};
When visiting the page, it correctly displays 1 2. But going back and forward in history, it displays 2 2. Also, the first refresh gives 2 2 and following refreshes display 1 2 again.