A library for creating CLIs with agnostic primitives like View, Text, Image, TextInput, etc...
Install react-native-ink
in your project.
yarn add react-native-ink
Alias react-native
to react-native-ink
:
-
yarn add -D babel-plugin-module-resolver
-
Create alias:
babel.config.js
module.exports = { // ... plugins: [ [ 'babel-plugin-module-resolver', { alias: { 'react-native': 'react-native-ink', }, }, ], ], };
import React, { useEffect, useState } from 'react';
import { AppRegistry, View, Text, Image, TextInput } from 'react-native';
const Counter = () => {
const [counter, setCounter] = useState(0);
useEffect(() => {
const timer = setInterval(() => {
setCounter(prevCounter => prevCounter + 1);
});
return () => {
clearInterval(timer);
};
});
return (
<View style={{ padding: 1 }}>
<Text style={{ color: 'green' }}>{counter} tests passed</Text>
</View>
);
};
AppRegistry.registerComponent('main', () => Counter);
The Expo source code is made available under the MIT license. Some of the dependencies are licensed differently, with the BSD license, for example.