1.2.2 • Published 3 years ago

mimic-react-native v1.2.2

Weekly downloads
-
License
MIT
Repository
github
Last release
3 years ago

mimic-react-native

Used to mimic react-native components in react-dom

Click here to see in npmjs.com

Under Development

NPM JavaScript Style Guide

Install

npm install mimic-react-native

Usage

Changing from react-native to react-dom

Change react-native imports to mimic-react-native

E.g:

import {View, Text} from 'react-native' //DELETE
import {View, Text} from 'mimic-react-native' //ADD

Using Directly in react-dom

import React, { useState } from 'react'

//Only these components are currently functioning. This library is still under development.
import {
  View,
  Text,
  TextInput,
  ScrollView,
  Button,
  Switch,
  Flatlist
} from 'mimic-react-native'

const ExampleApp = () => {
  const [checked, setChecked] = useState(false)
  return (
    <View>
      <Text style={{ color: 'red' }}>five</Text>
      <TextInput onChangeText={() => console.log(5)} />
      <ScrollView>5</ScrollView>
      <Button>button</Button>
      <Switch onValueChange={() => setChecked(!checked)} value={checked} />
      <FlatList
        keyExtractor={(item) => item.key}
        data={data}
        renderItem={({ item }: any) => <p>{item.name}</p>}
      />
    </View>
  )
}

export default App

API:

<View>, <ScrollView>, <SafeAreaView>

These three are the same component exported in different names.

import { View } from 'mimic-react-native'

export default function () {
  return <View {...props}>{children}</View>
}
propvaluerequired
childrenReact.ReactNode (or) stringNo
styleReact.CSSPropertiesNo
classNamestringNo
idstringNo

<Text>

import { View, Text } from 'mimic-react-native'

export default function () {
  return (
    <View>
      <Text elementType='h1'>children</Text>
    </View>
  )
}
propAllowed valuesrequireddefault
elementType'p', 'h1', 'h2', 'h3', 'h4', 'h5', 'h6', 'a'No'p'
childrenReact.ReactNode (or) stringYes
styleReact.CSSPropertiesNo
classNamestringNo
idstringNo

<Image>

import { View, Image } from 'mimic-react-native'

export default function () {
  return (
    <View>
      <Image source={{ uri: 'image://url' }} />
    </View>
  )
}
propAllowed valuesrequired
source{ uri: string }Yes
styleReact.CSSPropertiesNo
classNamestringNo
idstringNo

<TextInput>

import { View, TextInput } from 'mimic-react-native'

export default function () {
  return (
    <View>
      <TextInput />
    </View>
  )
}
propvaluerequired
valuenumber (or) stringNo
onChangeText (or) onChangefunction(newValue) { }No
childrenReact.ReactNode (or) stringNo
styleReact.CSSPropertiesNo
classNamestringNo
idstringNo

<Button>

import { Button } from 'mimic-react-native'

export default function () {
  return (
    <Button color='red' textColor='black'>
      TEXT
    </Button>
  )
}
propvaluerequireddefault
dontCapitalizebooleanNofalse
colorstringNo"rgb(33, 150, 243)"
textColorstringNo"#FFF"
onPress (or) onClickfunctionNo
childrenReact.ReactNode (or) stringNo
styleReact.CSSPropertiesNo
classNamestringNo
idstringNo

<Switch>

import { Switch } from 'mimic-react-native'

export default function () {
  return <Switch />
}
propvaluerequireddefault
sizenumberNo20
valuebooleanyesfalse
onValueChangefunction(newValue) { }No
thumbColorstringNo'silver'
trackColor{ true: string, false: string }No{ true: '#81b0ff', false: '#767577' }
childrenReact.ReactNode (or) stringNo
styleReact.CSSPropertiesNo
classNamestringNo
idstringNo

<FlatList>

import { FlatList } from 'mimic-react-native'

export default function () {
  const data = [
    {
      key: 1,
      name: 'a'
    },
    {
      key: 2,
      name: 'b'
    },
    {
      key: 3,
      name: 'c'
    }
  ]
  return (
    <FlatList
      keyExtractor={(item) => item.key}
      data={data}
      renderItem={({ item }: any) => <p>{item.name}</p>}
    />
  )
}
propvaluerequireddefault
data any No
renderItem({ item }) => \No
keyExtractor(item) => keyNo
childrenReact.ReactNode (or) stringNo
styleReact.CSSPropertiesNo
classNamestringNo
idstringNo

License

MIT © david-sling

1.2.2

3 years ago

1.2.1

3 years ago

1.2.0

3 years ago

1.1.5

3 years ago

1.1.1

3 years ago

1.0.1

3 years ago