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-collapsible-touchable-child-fix

v0.7.0

Published

Quickest fix for 'Touchable child must either be native or forward setNativeProps to a native component' when working with rn 0.31.0 and router-flux

Downloads

3

Readme

react-native-collapsible

Animated collapsible component for React Native using the Animated API

Pure JavaScript, supports dynamic content heights and components that is aware of its collapsed state (good for toggling arrows etc).

Installation

npm install --save react-native-collapsible

Collapsible Usage

import Collapsible from 'react-native-collapsible';
<Collapsible collapsed={isCollapsed}>
  <SomeCollapsedView />
</Collapsible>

Properties

| Prop | Description | Default | |---|---|---| |align|Alignment of the content when transitioning, can be top, center or bottom|top| |collapsed|Wether to show the child components or not|true| |collapsedHeight|Which height should the component collapse to|0| |duration|Duration of transition in milliseconds|300| |easing|Function or function name from Easing (or tween-functions if < RN 0.8). Collapsible will try to combine Easing functions for you if you name them like tween-functions. |easeOutCubic|

Accordion Usage

This is a convenience component for a common use case, see demo below.

import Accordion from 'react-native-collapsible/Accordion';
<Accordion 
  sections={['Section 1', 'Section 2', 'Section 3']}
  renderHeader={this._renderHeader}
  renderContent={this._renderContent}
/>

Properties

| Prop | Description | |---|---|---| |sections|An array of sections passed to the render methods| |renderHeader(content, index, isActive)|A function that should return a renderable representing the header| |renderContent(content, index, isActive)|A function that should return a renderable representing the content| |onChange(index)|An optional function that is called when currently active section is changed, index === false when collapsed| |initiallyActiveSection|Set which index in the sections array is initially open. Defaults to none. | |activeSection|Control which index in the sections array is currently open. Defaults to none. If false, closes all sections.| |underlayColor|The color of the underlay that will show through when tapping on headers. Defaults to black. | |align|See Collapsible| |duration|See Collapsible| |easing|See Collapsible|

Demo

demo

Example

Check full example in the Example folder.

import React, { Component } from 'react-native';
import Accordion from 'react-native-collapsible/Accordion';

const SECTIONS = [
  {
    title: 'First',
    content: 'Lorem ipsum...',
  },
  {
    title: 'Second',
    content: 'Lorem ipsum...',
  }
];

class AccordionView extends Component {
  _renderHeader(section) {
    return (
      <View style={styles.header}>
        <Text style={styles.headerText}>{section.title}</Text>
      </View>
    );
  }

  _renderContent(section) {
    return (
      <View style={styles.content}>
        <Text>{section.content}</Text>
      </View>
    );
  }

  render {
    return (
      <Accordion
        sections={SECTIONS}
        renderHeader={this._renderHeader}
        renderContent={this._renderContent}
      />
    );
  }
}

Transition backgrounds

If you combine with the react-native-animatable library you can easily transition the background color between the active and inactive state or add animations.

Lets augment the example above with:

import * as Animatable from 'react-native-animatable';

(...)

  _renderHeader(section, index, isActive) {
    return (
      <Animatable.View
        style={styles.header}
        duration={300}
        transition="backgroundColor"
        style={{ backgroundColor: (isActive ? 'rgba(255,255,255,1)' : 'rgba(245,252,255,1)') }}>
        <Text style={styles.headerText}>{section.title}</Text>
      </Animatable.View>
    );
  }

  _renderContent(section, i, isActive) {
    return (
      <Animatable.View
        style={styles.content}
        duration={300}
        transition="backgroundColor"
        style={{ backgroundColor: (isActive ? 'rgba(255,255,255,1)' : 'rgba(245,252,255,1)') }}>
        <Animatable.Text
          duration={300}
          easing="ease-out"
          animation={isActive ? 'zoomIn' : false}>
          {section.content}
        </Animatable.Text>
      </Animatable.View>
    );
  }

(...)

To produce this (slowed down for visibility):

accordion-demo

License

MIT License. © Joel Arvidsson 2015