-
-
Notifications
You must be signed in to change notification settings - Fork 4
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
- Loading branch information
1 parent
bd37a83
commit f751f8e
Showing
6 changed files
with
92 additions
and
4 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,70 @@ | ||
'use client'; | ||
import React from 'react'; | ||
import { useUrlState } from 'state-in-url'; | ||
|
||
import { form } from './form'; | ||
// import { useUrlState } from '../../../../dist'; | ||
|
||
const Status = ({ className, sp }: { className?: string; sp?: object }) => { | ||
const { state } = useUrlState(form, sp); | ||
|
||
return ( | ||
<div className={className}> | ||
<div className="font-semibold mb-2 text-black"> | ||
Other client component | ||
</div> | ||
<h3 className="text-black">Types and structure of data are presered</h3> | ||
|
||
<div className="flex-none "> | ||
<pre | ||
className="h-[330px] text-sm overflow-y-scroll | ||
text-gray-600 bg-white p-4 rounded-md shadow-inner | ||
break-all whitespace-pre-wrap" | ||
data-testid="parsed" | ||
> | ||
{JSON.stringify(state, null, 2)} | ||
</pre> | ||
</div> | ||
</div> | ||
); | ||
}; | ||
|
||
const Wrapper = (props: Parameters<typeof Status>) => { | ||
const [key, setKey] = React.useState(Math.random()); | ||
|
||
return ( | ||
<div> | ||
<Status key={key} {...props} /> | ||
<button | ||
onClick={() => setKey(Math.random())} | ||
className="text-black p-4" | ||
data-testid="remount" | ||
> | ||
remount | ||
</button> | ||
</div> | ||
); | ||
}; | ||
|
||
export { Wrapper as Status }; | ||
|
||
// TODO: move to main lib | ||
// function usePrevious<T>(value: T) { | ||
// const ref = React.useRef(value); | ||
|
||
// React.useEffect(() => { | ||
// if (JSON.stringify(value) !== JSON.stringify(ref.current)) { | ||
// ref.current = value; | ||
// } | ||
// }, [value]); | ||
|
||
// return ref.current; | ||
// } | ||
|
||
// function useChangedValue<T>(value: T) { | ||
// const valuePrev = usePrevious(value); | ||
|
||
// return JSON.stringify(value) !== JSON.stringify(valuePrev) | ||
// ? value | ||
// : valuePrev; | ||
// } |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters