STORE
import {useLocalObservable} from "mobx-react-lite";
export function chatMsgStore() {
let chatmessages = []
function setChatmessages(msgsArr) {
chatmessages = msgsArr
}
return {chatmessages, setChatmessages}
}
export const chatmsgstore = () => useLocalObservable(chatMsgStore)
прокидываю через контекст
import {chatmsgstore} from "./src/store/chatmessages";
const App = () => {
const AppFunctions = {chatmsgstore}
return (<>
<AppContext.Provider value={AppFunctions}>
................................
</AppContext.Provider>
</>
)
};
пытаюсь дернуть внутри другого компонента
export function ChatApp() {
const {chatmsgstore} = useContext(AppContext)
console.log(chatmsgstore.chatmessages) <------ undefined ???
chatmsgstore.setChatmessages([123,123,123]) <------- undefined is not a function???
return ...............
}