Package Exports
- @applicaster/zapp-react-native-utils/analyticsUtils
- @applicaster/zapp-react-native-utils/analyticsUtils/manager
- @applicaster/zapp-react-native-utils/appUtils/HooksManager
- @applicaster/zapp-react-native-utils/appUtils/HooksManager/constants
- @applicaster/zapp-react-native-utils/appUtils/RiverFocusManager
- @applicaster/zapp-react-native-utils/appUtils/playerManager
- @applicaster/zapp-react-native-utils/arrayUtils
- @applicaster/zapp-react-native-utils/functionUtils
- @applicaster/zapp-react-native-utils/navigationUtils
- @applicaster/zapp-react-native-utils/navigationUtils/itemTypes
- @applicaster/zapp-react-native-utils/objectUtils
- @applicaster/zapp-react-native-utils/pluginUtils
- @applicaster/zapp-react-native-utils/reactUtils
- @applicaster/zapp-react-native-utils/reactUtils/createContext
- @applicaster/zapp-react-native-utils/rectUtils
- @applicaster/zapp-react-native-utils/stylesUtils
This package does not declare an exports field, so the exports above have been automatically detected and optimized by JSPM instead. If any package subpath is missing, it is recommended to post an issue to the original package (@applicaster/zapp-react-native-utils) to support the "exports" field. If that is not possible, create a JSPM override to customize the exports field for this package.
Readme
@applicaster/zapp-react-native-utils
This package contains js utilities for the Quick Brick App
Contributing
- Follow the steps in the main README to set up the Zapp-React-Native repo, and run the app.
- add your folder or file
- import it with
import { utility } from "@applicaster/zapp-react-native-utils/utility";
API
reactUtils
@applicaster/zapp-react-native-utils/reactUtils
attachLifeCycleMethods = (lifecycleMethods: { [name]: method }) => (Component) =>
adds lifecycle methods to any React component (stateless or class). The appropriate method will be used depending on the type of the component. If the component is stateless, it will wrap it in a class before it adds the method to the Component's prototype.
Supports all React lifecycle methods except constructor
and static getDerivedStateFromProps
import { attachLifeCycleMethods } from "@applicaster/zapp-react-native-utils/reactUtils";
const MyComponent = props => (
<View>
<Text>I'm component</Text>
</View>
);
const lifeCycleDecorator = attachLifeCycleMethods({
componentDidMount() {
console.log("I'm mounted");
},
componentWillUpdate(nextProps, nextState) {
console.log("component will change", nextProps, nextState);
},
});
export const ComponentWithLifeCycleMethods = lifeCycleDecorator(MyComponent);
stringUtils
@applicaster/zapp-react-native/stringUtils
capitalize: (input: string) => string
: sets the first letter of the input string as uppercasetoPascalCase: (input: string) => string
: transforms asnake_case
input string toPascalCase
@applicaster/zapp-react-native/objectUtils
All following functions are curried and can be either called by f(a, b)
or f(a)(b)
. They work like all curried Ramda functions
filterObj: (predicate: any => boolean) => (object: any) => object: any
uses the predicate function to filter an object values.mapKeys: (mapper: string => string) => (object: any) => (object: any)
maps over an object's keys and applies the mapper function to these keys. Curried function
stylesUtils
@applicaster/zapp-react-native/stylesUtils
fixColorHexCode: string => string
: transforms aAARRGGBB
hex code into aRRGGBBAA
hex code - this is required because React Native usesRRGGBBAA
colors, but Zapp Api providesAARRGGBB
pluginUtils
@applicaster/zapp-react-native/pluginUtils
findPluginByIdentifier: (identifier: string, plugins: {[string]: Plugin}) => Plugin
: find a plugin for a given identifier,in the provided map of available plugins. Returns the entire plugin.findPluginByType: (type: string, plugins: {[string]: Plugin}) => Plugin
: find a plugin for a given type, in the provided map of available plugins. Returns the callable plugin module.getNavigationPlugin: (type: string, plugins: {[string]: Plugin}, defaultComponents: ?{[string]: Plugin}
: resolves the navigation plugin to use for a given type, from a provided map of available plugins. If provided, will fallback to one of the defaultComponent.
navigationUtils
@applicaster/zapp-react-native/navigationUtils
getNavigationType: (category: "nav_bar" | "menu", navigations: [Navigations]) => string
: retrieves the type of navigation for a given category (either nav_bar or menu), from the navigation data in the rivers.jsongetPathAttributes: (pathname: string) => [{ screenType: string, screenId: string }]
: transforms a given route into a map of attributes for that specific route./foo/bar/baz/qux
becomes :
[
{ screenType: "foo", screenId: "bar" },
{ screenType: "baz", screenId: "qux" },
];
getItemType: (item: any) => string
: gets the type of a given item in a feed.getItemTargetId: (item: any) => string
: gets the target screen id for a given item in a feed.