Overview of Mobydick libraries for React Native
Mobydick is a collection of libraries designed to address common challenges and pressing problems encountered by React Native developers.
website·Indexed 30 days ago
https://lad-tech.github.io/mobydickA set of libraries designed to solve common problems for React Native developers. It includes a suite of modular packages such as @lad-tech/mobydick-core for core components, @lad-tech/mobydick-chart, @lad-tech/mobydick-calendar, @lad-tech/mobydick-markdown, @lad-tech/mobydick-utils, and @lad-tech/mobydick-drag-and-drop.
npm install @lad-tech/mobydick-core @lad-tech/mobydick-chart @shopify/react-native-skia react-native-reanimated react-native-gesture-handler@lad-tech/mobydick-core and react-native-markdown-display.npm install @lad-tech/mobydick-core react-native-markdown-display @lad-tech/mobydick-markdownnpm install @lad-tech/mobydick-core @lad-tech/mobydick-calendar react-native-calendarsnpm install @lad-tech/mobydick-utils@docusaurus/plugin-content-blog plugin. To create blog posts, add Markdown files or folders to the blog directory. Post dates are automatically extracted from filenames using the format YYYY-MM-DD-title.md (e.g., 2023-12-25-welcome.md) or from an index.md file within a dated folder (e.g., 2023-12-25-welcome/index.md). Using folders for posts is recommended for co-locating images with the content. Blog authors can be managed in the authors.yml file, and posts support tags.useLatest hook from @lad-tech/mobydick-utils returns a ref that always holds the most recent value of the provided state or prop. This is specifically useful for accessing current values inside asynchronous callbacks (like setTimeout or API calls) where a standard state variable would be captured as a stale value from the time the callback was created.import { useLatest } from "@lad-tech/mobydick-utils";
import { Button, Text, View } from "@lad-tech/mobydick-core";
import { Alert } from "react-native";
import React from "react";
const Demo = () => {
const [count, setCount] = React.useState(0);
// latestCount.current will always be the most recent value of count
const latestCount = useLatest(count);
const handleAlertClick = () => {
setTimeout(() => {
// Accesses the value at the time the alert triggers, not when the button was clicked
Alert.alert(`Latest count value: ${latestCount.current}`);
}, 3000);
}
return (
<View>
<Text>You clicked {count} times</Text>
<Button onPress={() => setCount(count + 1)}>Click me</Button>
<Button onPress={handleAlertClick}>Show alert</Button>
</View>
);
};npm install @lad-tech/mobydick-core react-native-reanimated react-native-gesture-handler @lad-tech/mobydick-drag-and-drop@docusaurus/plugin-content-blog plugin. To create blog posts, add Markdown files or folders to the blog directory. To co-locate images with a post, use a folder structure. The blog post date is automatically extracted from filenames using the format YYYY-MM-DD-title.md or by placing an index.md inside a folder named YYYY-MM-DD-title.# Example filename for date extraction
2023-12-25-welcome.md
# Example folder structure for co-locating images
2023-12-25-welcome/
├── index.md
└── image.pngInputField component is a reusable input field for forms. It supports different visual states via the type prop (using IInputsTypes), allows for titles and subtitles, and can be configured as a multiline text area or a secure text entry field. It inherits all standard React Native TextInput props.import { IInputsTypes, InputField } from '@lad-tech/mobydick-core';
const MyForm = () => {
return (
<View>
{/* Standard required input */}
<InputField
type={IInputsTypes.default}
title={'Login'}
placeholder={'login'}
required={true}
/>
{/* Password input with a toggleable visibility icon */}
<InputField
type={IInputsTypes.valid}
title={'Password'}
placeholder={'password'}
secureTextEntry={true}
rightIcon={<SimpleIcon name="icon-hide" />}
required={true}
/>
{/* Error state input */}
<InputField
type={IInputsTypes.wrong}
title={'Title'}
subtitle={'Error text'}
/>
{/* Disabled input */}
<InputField
type={IInputsTypes.disabled}
title={'Disabled field'}
disabled={true}
subtitle={'Subtitle'}
/>
{/* Multiline text area */}
<InputField
type={IInputsTypes.default}
title={'About:'}
placeholder={'Write something'}
multiline={true}
onChangeText={(text) => console.log(text)}
/>
</View>
);
};@lad-tech/keyboard-aware library is used to resolve keyboard-related layout and visibility issues when using forms in an application. Install the package via npm to begin using it.npm install @lad-tech/keyboard-awareusePopup hook from @lad-tech/mobydick-core allows you to control the visibility of a specific popup component. It returns a set of controller functions (open, close, and closeAll) that can be used to trigger the popup's lifecycle.import { usePopup } from '@lad-tech/mobydick-core';
const CustomPopup = () => {
return <div>Popup Content</div>;
};
const App = () => {
const { open, close, closeAll } = usePopup(CustomPopup);
return (
<button onClick={() => open({ /* params */ })}>Open Popup</button>
);
};