Open adamgen opened 3 weeks ago
As a walk around I implemented this custom, hacky, provider
const ZeroAxisDefaultSetter: FC<PropsWithChildren<{ value?: boolean }>> = ({
value,
}) => {
const [, setZeroXaxis] = useAtom(zeroXaxisAtom);
useEffect(() => {
typeof value === "boolean" && setZeroXaxis(true);
}, []);
return "";
};
export const ZeroAxisProvider: FC<PropsWithChildren<{ value?: boolean }>> = ({
children,
value,
}) => {
return (
<ScopeProvider atoms={[zeroXaxisAtom]}>
<ZeroAxisDefaultSetter value={value} />
{children}
</ScopeProvider>
);
};
Currently adding a default values is highly complicated tho it's a very common use case.
The proposal is to add this api: