@daria_pnf/basic-module
v1.0.3
Published
Cross-platform React Native library with Apollo Client and Redux Toolkit integration.
Maintainers
Readme
Basic Module
Cross-platform React Native library with Apollo Client and Redux Toolkit integration.
Installation
npm install basic-module @apollo/client @reduxjs/toolkit react-reduxUsage
import React from 'react';
import { View, Text } from 'react-native';
import { RootProvider, configure, useAppSelector } from 'basic-module';
configure({
apiEndpoint: 'https://api.example.com/graphql',
headers: {
'Content-Type': 'application/json',
},
});
function App() {
return (
<RootProvider>
<YourAppContent />
</RootProvider>
);
}
function YourAppContent() {
const state = useAppSelector(state => state);
return (
<View>
<Text>Your app content here</Text>
</View>
);
}
export default App;API
Providers
RootProvider- Combined provider for Redux and ApolloStoreProvider- Redux store providerApolloProvider- Apollo client provider
Configuration
configure(config)- Configure the librarysetAuthToken(token)- Set authentication tokenclearTokens()- Clear all tokens
Redux Hooks
useAppDispatch()- Typed dispatch hookuseAppSelector()- Typed selector hook
License
MIT
