2.11.7-rc.0 • Published 8 months ago

@hippy/react v2.11.7-rc.0

Weekly downloads
29
License
Apache-2.0
Repository
github
Last release
8 months ago

Hippy React

Write Hippy cross platform app with React.

Hippy Group

Introduction

hippy-react is the React binding for Hippy, the syntax just like React Native, but advantaged.

  • All of components support touch events.
  • Recyclable ListView is built-in.
  • Animation is depolyed at once.

How to use

Installation

Create a empty react project with create-react-app, then enter into the project and install hippy-react with npm:

npm install @hippy/react

Advanced topics

Custom component

Confirmed the new component name and methods with Native develop, then write new component:

import React from 'react';
import { callUIFunction } from '@hippy/react';

class CustomComponent extends React.Component {
  /**
   * Method for custom component.
   * Replace `[METHOD_NAME]` to real method name.
   */
  [METHOD_NAME](...args) {
    /**
     * Call the native UI Function
     * 
     * @param {ReactRef} instance - React Ref, use for get the component Id
     * @param {string} methodName - Native method name.
     * @param {any[]} args - Arguments of native method, **MUST BE IN ARRAY**
     */
    callUIFunction(this.instance, [METHOD_NAME], args);
  }

  render() {
    return (
      {
        /*
         * Custom component must define the `nativeName` props,
         * that mapping to native component name.
         */
      }
      <div nativeName="[NATIVE_COMPONENT_NAME]" ref={ref => this.instance = ref} />
    );
  }
}

Custom module

There are two implementation of modules

For the C++ module, the methods are injected into JS enviroment, just call the method.

For the modules implemented by Objective C or Java, use the callNative for execution.

const { callNative, callNativeWithPromise } from '@hippy/react';

const SomeModule = {
  /**
   * Method that not need repsonse
   */
  [MODULE_METHOD](...args) {
    callNative('ModuleName', 'MethodName', args);
  }
  /**
   * Method with reponse
   */
  [MODULE_METHOD_WITH_RESPONSE](...args) {
    return callNativeWithPromise('ModuleName', 'MethodWithResposne', args);
  }
}

The ModuleName, MethodName and arguments must be confirmed with native developers.

Migrate from React Native

The most difference in React Native and Hippy React have three points:

  1. Touch event system
  2. Animation
  3. Compoents

Touch event system

The touch event is able to apply to View component directly, for example the onPress event:

import React from 'react';
import { View, Text } from '@hippy/react';

function Container() {
  function clickHandler(eventName) {
    console.log(eventName, 'is trigged');
  }

  return (
    <View>
      { /* `onClick` event is supported to instead of `onPress`  */ }
      <View onClick={() => clickHandler('click')}><Text>Trigger click event</Text></View>

      { /* But `onPress`still supported for forward compatibility  */ }
      <View onPress={() => clickHandler('press')}><Text>Trigger click event</Text></View>
    </View>
  );
}
2.11.7-rc.0

8 months ago

3.3.2-rc.2

8 months ago

3.3.2-rc.1

8 months ago

3.3.1-rc.3

8 months ago

3.3.2-rc.0

8 months ago

2.15.5-alpha.2

10 months ago

2.15.5-alpha.0

10 months ago

2.15.5-alpha.1

10 months ago

3.3.1-alpha.0

10 months ago

2.17.6-alpha.1

11 months ago

2.14.4-rc.0

1 year ago

2.17.6-alpha.0

11 months ago

2.14.4-rc.3

1 year ago

2.14.4-rc.4

1 year ago

2.14.4-rc.1

1 year ago

2.14.4-rc.2

1 year ago

2.14.4-rc.5

1 year ago

2.17.5

11 months ago

2.16.2-rc.0

10 months ago

3.3.1-rc.2

10 months ago

3.3.1-rc.1

10 months ago

3.3.1-rc.0

12 months ago

3.3.1

10 months ago

3.3.0

12 months ago

3.2.0-beta

1 year ago

2.17.3

2 years ago

2.17.3-beta

2 years ago

3.0.2-beta

2 years ago

3.0.0-alpha.19

2 years ago

3.0.1

2 years ago

2.17.2

2 years ago

2.17.0

2 years ago

2.17.1

2 years ago

3.0.0

2 years ago

3.0.2-beta.2

2 years ago

3.0.0-alpha.21

2 years ago

3.0.0-alpha.20

2 years ago

3.0.0-alpha.22

2 years ago

2.16.5

2 years ago

3.0.0-alpha.18

2 years ago

3.0.0-alpha.17

2 years ago

2.16.4

2 years ago

3.0.0-alpha.14

2 years ago

3.0.0-alpha.13

2 years ago

3.0.0-alpha.16

2 years ago

3.0.0-alpha.15

2 years ago

3.0.0-alpha.10

2 years ago

3.0.0-alpha.11

2 years ago

2.16.3

2 years ago

2.16.1

2 years ago

2.16.2

2 years ago

2.16.0

2 years ago

3.0.0-alpha.9

3 years ago

2.15.4

3 years ago

2.15.5

3 years ago

2.15.2

3 years ago

2.15.3

3 years ago

3.0.0-alpha.8

3 years ago

2.15.0

3 years ago

2.15.1

3 years ago

3.0.0-alpha.7

3 years ago

2.14.7

3 years ago

2.14.5

3 years ago

2.14.6

3 years ago

3.0.0-alpha.6

3 years ago

3.0.0-alpha.4

3 years ago

2.14.3

3 years ago

2.14.4

3 years ago

2.14.1

3 years ago

2.14.2

3 years ago

2.14.0

3 years ago

2.13.10

3 years ago

3.0.0-alpha.3

3 years ago

2.13.8

3 years ago

2.13.9

3 years ago

3.0.0-alpha.1

3 years ago

2.13.7

3 years ago

2.13.4

3 years ago

2.13.2

3 years ago

2.13.1

3 years ago

2.12.4-beta1

3 years ago

2.12.4-beta2

3 years ago

2.12.4-beta3

3 years ago

2.12.4-beta4

3 years ago

2.12.4-beta5

3 years ago

2.12.4-beta6

3 years ago

2.12.3

3 years ago

2.12.4-beta7

3 years ago

2.12.4

3 years ago

2.12.4-beta8

3 years ago

2.12.4-beta9

3 years ago

2.13.0

3 years ago

2.11.6-alpha.2

3 years ago

2.12.0

3 years ago

2.12.1

3 years ago

2.12.2

3 years ago

2.12.0-beta

4 years ago

2.12.0-beta1

4 years ago

2.12.0-beta3

4 years ago

2.12.0-beta2

4 years ago

2.12.0-beta5

4 years ago

2.12.0-beta4

4 years ago

2.11.6

3 years ago

2.11.4

4 years ago

2.11.5

4 years ago

2.11.2

4 years ago

2.11.3

4 years ago

2.11.6-alpha.1

3 years ago

2.11.0

4 years ago

2.11.1

4 years ago

2.10.2

4 years ago

2.10.3

4 years ago

2.10.1

4 years ago

2.9.2

4 years ago

2.10.0

4 years ago

2.10.0-beta

4 years ago

2.9.1

4 years ago

2.9.0

4 years ago

2.8.4

4 years ago

2.8.3

4 years ago

2.8.1

4 years ago

2.8.2

4 years ago

2.8.0

4 years ago

2.7.6

4 years ago

2.7.4

4 years ago

2.6.5

4 years ago

2.7.3

4 years ago

2.7.2

4 years ago

2.7.0

4 years ago

2.7.1

4 years ago

2.6.1

4 years ago

2.6.3

4 years ago

2.6.2

4 years ago

2.6.4

4 years ago

2.6.0

4 years ago

2.5.5

4 years ago

2.5.4

4 years ago

2.5.2

4 years ago

2.5.3

4 years ago

2.5.1

4 years ago

2.5.0

4 years ago

2.3.4

4 years ago

2.3.3

4 years ago

2.3.2

4 years ago

2.3.1

4 years ago

2.3.0

4 years ago

2.2.2

4 years ago

2.2.1

4 years ago

2.2.0

4 years ago

2.1.6

4 years ago

2.1.5

5 years ago

2.1.4

5 years ago

2.1.2

5 years ago

2.1.1

5 years ago

2.1.0

5 years ago

2.0.3

5 years ago

2.0.2-next.5

5 years ago

2.0.2

5 years ago

2.0.2-next.4

5 years ago

2.0.2-next.3

5 years ago

2.0.2-next.2

5 years ago

2.0.2-next.1

5 years ago

2.0.1

5 years ago