https://github.com/kanzitelli/if-component
🤏 The tiniest missing component for React (Native). Can be used as a TS starter for building components and libraries.
https://github.com/kanzitelli/if-component
if-component justforfun react react-component-boilerplate react-component-library react-native
Last synced: about 2 months ago
JSON representation
🤏 The tiniest missing component for React (Native). Can be used as a TS starter for building components and libraries.
- Host: GitHub
- URL: https://github.com/kanzitelli/if-component
- Owner: kanzitelli
- Created: 2021-02-10T19:44:06.000Z (over 4 years ago)
- Default Branch: master
- Last Pushed: 2021-12-15T17:03:49.000Z (over 3 years ago)
- Last Synced: 2025-04-01T22:57:41.888Z (about 2 months ago)
- Topics: if-component, justforfun, react, react-component-boilerplate, react-component-library, react-native
- Language: TypeScript
- Homepage: https://www.npmjs.com/package/@kanzitelli/if-component
- Size: 124 KB
- Stars: 12
- Watchers: 2
- Forks: 1
- Open Issues: 0
-
Metadata Files:
- Readme: README.md
Awesome Lists containing this project
README
### Install it
```
yarn add @kanzitelli/if-component
```### Use it
```tsx
import {If} from '@kanzitelli/if-component';class OrdersScreen = () => {
return (
<>
}
_else={} />
>
)
}
```### Expo Web
Since `if-component` uses Reanimated 2, we need its babel plugin to be applied. Expo Web doesn't transpile modules by default, so we'll need to tell it to transpile the library.
1. Install `@expo/webpack-config`:
```
yarn add -D @expo/webpack-config
```2. Create `webpack.config.js` in the root of your project:
```
const createExpoWebpackConfigAsync = require('@expo/webpack-config')module.exports = async function (env, argv) {
const config = await createExpoWebpackConfigAsync(
{
...env,
babel: { dangerouslyAddModulePathsToTranspile: ['@kanzitelli/if-component'] },
},
argv
)return config
}
```Don't forget to add `webpack.config.js` into `tsconfig.json` under `exclude` section, if needed.
### TS lib starter
```bash
> git clone https://github.com/kanzitelli/if-component rn-lib
> cd rn-lib && rm -rf .git
> yarn
```Don't forget to change your lib's name in `package.json` and check other scripts.