项目作者: msamirma

项目描述 :
React Native With Expo and Native Base Dynamic form
高级语言: JavaScript
项目地址: git://github.com/msamirma/react-native-form-runtime.git
创建时间: 2018-10-04T19:26:10Z
项目社区:https://github.com/msamirma/react-native-form-runtime

开源协议:MIT License

下载


React Native Form Runtime

Form runtime is a react container that let you to have dynamic forms based on design json schema.

Sample output

Prerequisites

You must have installed Expo And Native base in your application.

Installing

  1. $ yarn add react-native-form-runtime

Simple Example

  1. import FormRuntime from "react-native-form-runtime";
  2. ...
  3. const formDesign = [
  4. {
  5. type: "Text",
  6. field: "firstName",
  7. label: "First Name"
  8. },
  9. {
  10. type: "Number",
  11. field: "age",
  12. label: "Age"
  13. },
  14. {
  15. type: "Picker",
  16. field: "gender",
  17. label: "Select Gender",
  18. options: ["Male", "Female"]
  19. }
  20. ];
  21. ...
  22. _submit(formData: {}, ACTION: string) {
  23. console.log(formData);
  24. }
  25. ...
  26. <FormRuntime
  27. formDesign={formDesign}
  28. type="submit"
  29. submit={this._submit.bind(this)}
  30. ></FormRuntime>

Available Properties

Property Type Description
formDesign Array of objects Array holds number of fields in form
type string Action will be taken when click on submit
submit function Function will be called to submit your data to server for example.

Available Fields ( Type in form design array)

Field Description
Text simple text input
Number simple number input
Checkbox simple checkbox
Label text field
Picker picker . MUST have options property .

Todo

  • View Mode
  • Form validation
  • Flow Typed And Linting
  • Test
  • Add Picker Field
  • Add more fields (Cont.)
  • Add Example (Cont.)