2.17.3 • Published 1 month ago

@hippy/react v2.17.3

Weekly downloads
29
License
Apache-2.0
Repository
github
Last release
1 month 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>
  );
}
3.2.0-beta

1 month ago

2.17.3

5 months ago

2.17.3-beta

5 months ago

3.0.2-beta

9 months ago

3.0.0-alpha.19

10 months ago

3.0.1

9 months ago

2.17.2

9 months ago

2.17.0

9 months ago

2.17.1

9 months ago

3.0.0

11 months ago

3.0.2-beta.2

8 months ago

3.0.0-alpha.21

10 months ago

3.0.0-alpha.20

10 months ago

3.0.0-alpha.22

10 months ago

2.16.5

10 months ago

3.0.0-alpha.18

12 months ago

3.0.0-alpha.17

12 months ago

2.16.4

12 months ago

3.0.0-alpha.14

1 year ago

3.0.0-alpha.13

1 year ago

3.0.0-alpha.16

1 year ago

3.0.0-alpha.15

1 year ago

3.0.0-alpha.10

1 year ago

3.0.0-alpha.11

1 year ago

2.16.3

1 year ago

2.16.1

1 year ago

2.16.2

1 year ago

2.16.0

1 year ago

3.0.0-alpha.9

2 years ago

2.15.4

1 year ago

2.15.5

1 year ago

2.15.2

2 years ago

2.15.3

1 year ago

3.0.0-alpha.8

2 years ago

2.15.0

2 years ago

2.15.1

2 years ago

3.0.0-alpha.7

2 years ago

2.14.7

2 years ago

2.14.5

2 years ago

2.14.6

2 years ago

3.0.0-alpha.6

2 years ago

3.0.0-alpha.4

2 years ago

2.14.3

2 years ago

2.14.4

2 years ago

2.14.1

2 years ago

2.14.2

2 years ago

2.14.0

2 years ago

2.13.10

2 years ago

3.0.0-alpha.3

2 years ago

2.13.8

2 years ago

2.13.9

2 years ago

3.0.0-alpha.1

2 years ago

2.13.7

2 years ago

2.13.4

2 years ago

2.13.2

2 years ago

2.13.1

2 years ago

2.12.4-beta1

2 years ago

2.12.4-beta2

2 years ago

2.12.4-beta3

2 years ago

2.12.4-beta4

2 years ago

2.12.4-beta5

2 years ago

2.12.4-beta6

2 years ago

2.12.3

2 years ago

2.12.4-beta7

2 years ago

2.12.4

2 years ago

2.12.4-beta8

2 years ago

2.12.4-beta9

2 years ago

2.13.0

2 years ago

2.11.6-alpha.2

2 years ago

2.12.0

2 years ago

2.12.1

2 years ago

2.12.2

2 years ago

2.12.0-beta

2 years ago

2.12.0-beta1

2 years ago

2.12.0-beta3

2 years ago

2.12.0-beta2

2 years ago

2.12.0-beta5

2 years ago

2.12.0-beta4

2 years ago

2.11.6

2 years ago

2.11.4

2 years ago

2.11.5

2 years ago

2.11.2

2 years ago

2.11.3

2 years ago

2.11.6-alpha.1

2 years ago

2.11.0

2 years ago

2.11.1

2 years ago

2.10.2

3 years ago

2.10.3

2 years ago

2.10.1

3 years ago

2.9.2

3 years ago

2.10.0

3 years ago

2.10.0-beta

3 years ago

2.9.1

3 years ago

2.9.0

3 years ago

2.8.4

3 years ago

2.8.3

3 years ago

2.8.1

3 years ago

2.8.2

3 years ago

2.8.0

3 years ago

2.7.6

3 years ago

2.7.4

3 years ago

2.6.5

3 years ago

2.7.3

3 years ago

2.7.2

3 years ago

2.7.0

3 years ago

2.7.1

3 years ago

2.6.1

3 years ago

2.6.3

3 years ago

2.6.2

3 years ago

2.6.4

3 years ago

2.6.0

3 years ago

2.5.5

3 years ago

2.5.4

3 years ago

2.5.2

3 years ago

2.5.3

3 years ago

2.5.1

3 years ago

2.5.0

3 years ago

2.3.4

3 years ago

2.3.3

3 years ago

2.3.2

3 years ago

2.3.1

3 years ago

2.3.0

3 years ago

2.2.2

3 years ago

2.2.1

3 years ago

2.2.0

3 years ago

2.1.6

3 years ago

2.1.5

3 years ago

2.1.4

3 years ago

2.1.2

3 years ago

2.1.1

4 years ago

2.1.0

4 years ago

2.0.3

4 years ago

2.0.2-next.5

4 years ago

2.0.2

4 years ago

2.0.2-next.4

4 years ago

2.0.2-next.3

4 years ago

2.0.2-next.2

4 years ago

2.0.2-next.1

4 years ago

2.0.1

4 years ago