npm package discovery and stats viewer.

Discover Tips

  • General search

    [free text search, go nuts!]

  • Package details

    pkg:[package-name]

  • User packages

    @[username]

Sponsor

Optimize Toolset

I’ve always been into building performant and accessible sites, but lately I’ve been taking it extremely seriously. So much so that I’ve been building a tool to help me optimize and monitor the sites that I build to make sure that I’m making an attempt to offer the best experience to those who visit them. If you’re into performant, accessible and SEO friendly sites, you might like it too! You can check it out at Optimize Toolset.

About

Hi, 👋, I’m Ryan Hefner  and I built this site for me, and you! The goal of this site was to provide an easy way for me to check the stats on my npm packages, both for prioritizing issues and updates, and to give me a little kick in the pants to keep up on stuff.

As I was building it, I realized that I was actually using the tool to build the tool, and figured I might as well put this out there and hopefully others will find it to be a fast and useful way to search and browse npm packages as I have.

If you’re interested in other things I’m working on, follow me on Twitter or check out the open source projects I’ve been publishing on GitHub.

I am also working on a Twitter bot for this site to tweet the most popular, newest, random packages from npm. Please follow that account now and it will start sending out packages soon–ish.

Open Software & Tools

This site wouldn’t be possible without the immense generosity and tireless efforts from the people who make contributions to the world and share their work via open source initiatives. Thank you 🙏

© 2024 – Pkg Stats / Ryan Hefner

react-native-flexible-button

v1.0.7

Published

a simple react-native component

Downloads

6

Readme

Install

npm install react-native-flexible-button  --save

仓库地址: https://github.com/yylgit/react-native-flexible-button.git

API

Props |Type| Description ---|---|--- text | PropTypes.string | 按钮显示的文本,当按钮有子元素时,将覆盖text onPress | PropTypes.func | 传递点击事件 size | PropTypes.string | 控制按钮的大小,可取的值为:xs、sm、default、lg,默认default type | PropTypes.string | 控制按钮的颜色,可取的值为:default、primary、success、info 、warning、danger、link、main,默认default activityIndicatorColor | PropTypes.string | 控制loading的颜色,默认white containerStyle | View.propTypes.style | 自定义按钮外层的样式 textStyle | Text.propTypes.style | 自定义按钮文本的样式 isLoading | PropTypes.bool | 是否在加载中的属性 disabled | PropTypes.bool | 是否在disabled状态 disabledContainerStyle | View.propTypes.style | 自定义disabled状态按钮外层的样式 disabledTextStyle | Text.propTypes.style | 自定义disabled状态按钮文本的样式 props | | 可以指定任意TouchableOpacity的属性,都会透传过去,例如常用的onPressIn、onPressOut、onLongPress等等。 children | string, number, React.Element,or array | children指代button里的子节点,如果子节点是string或者number类型,则渲染在Text元素内,如果是array或者React.Element类型则直接渲染。

example


import React, { Component } from 'react';

import {
  StyleSheet,
  View,
  Text
} from 'react-native';

import Button from '@scfe/react-native-button';
import Icon from 'react-native-vector-icons/FontAwesome';
class TestButton extends Component {
  render() {
    return (
      <View style={styles.container}>
        <View style={styles.row}>
      <Button size='lg' text="(大按钮)size='lg'" />
        </View>
        <View style={styles.row}>
      <Button  text="(默认尺寸)" />
        </View>
        <View style={styles.row}>
      <Button size='sm'   text="(小按钮) size='sm'" />
        </View>
        <View style={styles.row}>
      <Button size='xs'   text="(超小尺寸) size='xs'" />
        </View>
        <View style={styles.row}>
      <Button type="default"  text="(默认样式)type=default" />
        </View>
        <View style={styles.row}>
      <Button type="primary"  text="(首选项)type=type=primary" />
        </View>
        <View style={styles.row}>
      <Button type="success"  text="(成功)type=success" />
        </View>
        <View style={styles.row}>
      <Button type="info"  text="(一般信息)type=info" />
        </View>
        <View style={styles.row}>
      <Button type="warning"  text="(警告)type=warning" />
        </View>
        <View style={styles.row}>
      <Button type="danger"  text="(危险)type=danger" />
        </View>
        <View style={styles.row}>
      <Button type="main"  text="(美团色)type=main" />
        </View>
        <View style={styles.row}>
      <Button  type="link" text="(链接)Link" />
        </View>
        <View style={styles.row}>
      <Button  disabled={true} text="disabled" />
        </View>
        <View style={styles.row}>
      <Button  isLoading={true} activityIndicatorColor="black" text="loading" />
        </View>
        <View style={styles.row}>
      <Button type="danger" isLoading={true}  text="loading" />
        </View>


        <View style={styles.row}>
          <Button>
            <View style={{flexDirection: 'row'}}>
              <Icon name={"desktop"} size={18} color='#000'/>
              <Text style={{marginLeft: 5}}>自定义内容</Text>
            </View>
          </Button>
        </View>

      </View>
    );
  }
}

const styles = StyleSheet.create({
  container: {
    flex: 1,
    paddingTop: 20,
    paddingLeft: 10,
    paddingRight: 10
  },
  row: {
    marginTop: 5
  }
});

export default TestButton;

Screenshots

image description

使用RT开发组件

使用rt工具开发React Native组件

使用rt生成的RN版本较低,需要升级React-Native

这里升级成如下版本

"dependencies": {
    "react": "15.3.0",
    "react-native": "0.32.0"
  }
升级后,直接运行如果build fail

解决办法:

TARGETS->Build Settings->Link->Other Linker Flags 下添加-lc++

image description

如果遇到js报错,是babel的原因 image description

transforming [========================================] 100% 399/400Error while persisting cache: TransformError: /Users/zzx/MyProject/node_modules/react-deep-force-update/lib/index.js: [BABEL] /Users/zzx/MyProject/node_modules/react-deep-force-update/lib/index.js: Unknown option: /Users/zzx/MyProject/node_modules/react-deep-force-update/.babelrc.stage

原因: 新版本用的是babel 6版本,可是有些依赖的库并不是这个版本,就会导致这个错,所以解决方案就是把babel删了,升级依赖。

解决方法:

尝试1:

手动删除/Users/zzx/MyProject/node_modules/react-deep-force-update/.babelrc 然后重启就解决了

尝试2:

修改package.json文件

"scripts": {
  "clean:babelrc": "find ./node_modules -name react-packager -prune -o -name '.babelrc' -print | xargs rm -f",
  "postinstall": "npm run clean:babelrc"
}

删除依赖重新安装

rm -rf node_modules
npm install