ump-core
v0.0.1
Published
Platform-agnostic runtime for [UMP](https://git.n.xiaomi.com/zhoujianlin/ump). The `react` peer in UMP's `react` + `react-native` split:
Downloads
978
Readme
ump-core
Platform-agnostic runtime for UMP.
The react peer in UMP's react + react-native split:
- JSX runtime:
createElement,Fragment,jsx/jsxs. - Hooks:
useState,useEffect,useRef,useMemo,useCallback,useReducer,useLayoutEffect,useImperativeHandle,useId,createContext/useContext. forwardRef,memo,ErrorBoundary/useErrorBoundary,render,createPortal.- Module / refresh registry used by Fast Refresh.
ump-core does not ship native components or browser-globals
polyfills. Pair it with ump-native
(or ump-h5-native for the
browser).
Install
npm install ump-core ump-nativeUsage
UMP uses the automatic JSX runtime (jsx: "react-jsx" +
jsxImportSource: "ump-core"), so <View> and <></> work
without per-file createElement / Fragment imports.
import { useState } from 'ump-core';
import { View, Text, Pressable } from 'ump-native';
export default function Counter() {
const [n, setN] = useState(0);
return (
<View>
<Text>Count: {n}</Text>
<Pressable onPress={() => setN(n + 1)}>
<Text>+1</Text>
</Pressable>
</View>
);
}See the main README for the full component matrix and platform support.
License
MIT — see LICENSE.
