diff --git a/dist/index.js b/dist/index.js index f5208b5..4736628 100644 --- a/dist/index.js +++ b/dist/index.js @@ -36589,22 +36589,6 @@ var useStore = (options) => { const store = (0, import_react2.useContext)(StoreContext); return (options == null ? void 0 : options.store) || store || getDefaultStore(); }; -var Provider = ({ - children, - store -}) => { - const storeRef = (0, import_react2.useRef)(); - if (!store && !storeRef.current) { - storeRef.current = createStore(); - } - return (0, import_react2.createElement)( - StoreContext.Provider, - { - value: store || storeRef.current - }, - children - ); -}; var isPromiseLike2 = (x) => typeof (x == null ? void 0 : x.then) === "function"; var use = import_react2.default.use || ((promise) => { if (promise.status === "pending") { @@ -36684,11 +36668,13 @@ function useAtom(atom2, options) { // src/Picker.tsx var import_jsx_runtime3 = __toESM(require_jsx_runtime(), 1); -function Picker({ $options, $isLoading, $url, $isEnabled, $selectedOption }) { - $options = $options || (0, import_react3.useMemo)(() => atom([]), []); - $isLoading = $isLoading || (0, import_react3.useMemo)(() => atom(true), []); - $isEnabled = $isEnabled || (0, import_react3.useMemo)(() => atom(true), []); - $selectedOption = $selectedOption || (0, import_react3.useMemo)(() => atom(""), []); +function Picker({ + $url, + $options = (0, import_react3.useMemo)(() => atom([]), []), + $isLoading = (0, import_react3.useMemo)(() => atom(true), []), + $isEnabled = (0, import_react3.useMemo)(() => atom(true), []), + $selectedOption = (0, import_react3.useMemo)(() => atom(""), []) +}) { const url = useAtomValue($url); const options = useAtomValue($options); const isLoading = useAtomValue($isLoading); @@ -36703,14 +36689,14 @@ function Picker({ $options, $isLoading, $url, $isEnabled, $selectedOption }) { fetch(url).then((x) => x.json()).catch((err) => ["AAPL", "MSFT", "GOOG"]).then(optionsFetched); } }, [url, isEnabled]); - return /* @__PURE__ */ (0, import_jsx_runtime3.jsx)(Provider, { children: /* @__PURE__ */ (0, import_jsx_runtime3.jsx)("div", { children: isLoading ? /* @__PURE__ */ (0, import_jsx_runtime3.jsx)("span", { children: "Loading..." }) : /* @__PURE__ */ (0, import_jsx_runtime3.jsxs)("select", { value: selectedOption, onChange: (e) => { + return /* @__PURE__ */ (0, import_jsx_runtime3.jsx)("div", { children: isLoading ? /* @__PURE__ */ (0, import_jsx_runtime3.jsx)("span", { children: "Loading..." }) : /* @__PURE__ */ (0, import_jsx_runtime3.jsxs)("select", { value: selectedOption, onChange: (e) => { setSelectedOption(e.target.value); }, children: [ /* @__PURE__ */ (0, import_jsx_runtime3.jsx)("option", { value: "" }, ""), options.map( (date) => /* @__PURE__ */ (0, import_jsx_runtime3.jsx)("option", { value: date, children: date }, date) ) - ] }) }) }); + ] }) }); } // src/App.module.css diff --git a/src/Picker.tsx b/src/Picker.tsx index 39760d9..c3a7a71 100644 --- a/src/Picker.tsx +++ b/src/Picker.tsx @@ -1,5 +1,5 @@ import { useEffect, useMemo } from "react"; -import { atom as $, useAtom, Atom, PrimitiveAtom, useAtomValue, useSetAtom, Provider } from 'jotai'; +import { atom as $, useAtom, Atom, PrimitiveAtom, useAtomValue, useSetAtom, } from 'jotai'; type PickerInput = { $options?:PrimitiveAtom>, @@ -36,7 +36,6 @@ export function Picker({ },[url, isEnabled]) return ( -
{isLoading ? @@ -50,6 +49,5 @@ export function Picker({ }
-
); } \ No newline at end of file