@kravc/mobx-create-store
v0.5.0
Published
MobX create store helper for react native
Downloads
3
Readme
@kravc/mobx-create-store
MobX create store helper for react native.
Usage Example
npm i --save @kravc/mobx-create-store
npm i --save @react-native-async-storage/async-storage
Define store class:
import AsyncStorage from '@react-native-async-storage/async-storage'
import { createStore } from '@kravc/mobx-create-store'
const observables = {
lastName: '',
firstName: ''
}
class ProfileStore extends createStore(AsyncStorage, '@profile_v1', observables) {
}
export default ProfileStore
Initialize store via useStore
hook:
import React from 'react'
import { useStore, observer } from '@kravc/mobx-create-store'
import ProfileStore from './ProfileStore'
const App = function () {
const [ store ] = useStore(ProfileStore)
const isLoading = !store
if (isLoading) {
return null
}
return (
<View store={store} />
)
}
export default observer(App)
Check out interface for more usage examples.