RecoilRoot.js
实现
import React, { useRef } from "react";
import AppContext from "./appContext";
function RecoilRoot(props) {
const { children } = props;
const state = {};
const store = { getState: () => state };
const storeRef = useRef(store);
return <AppContext.Provider value={storeRef}>{children}</AppContext.Provider>;
}
export default RecoilRoot;