Git Product home page Git Product logo

react-native-jsonschema-form's Introduction

react-json-schema-form themed for react-native

Getting Started

yarn add @rjsf/core rjsf-native

# This package also depends on `@react-native-community/slider`
yarn add @react-native-community/slider

Usage

import ReactNativeForm from 'rjsf-native';

const App = () => {
  const form = useRef(null);
  return (
    <ReactNativeForm
      ref={form}
      onError={e => {
        console.log(e);
        Alert.alert('Please check your form');
      }}
      schema={schema}
      uiSchema={uiSchema}
      onSubmit={form => console.log(form.formData)}>
      <Button
        title="Submit"
        onPress={() => {
          form.current?.submit();
        }}
      />
    </ReactNativeForm>
  );
};

We also provide a Context as a form of overriding defaults and theming

import ReactNativeForm, {defaultProps, FormContext} from 'rjsf-native';

const App = () => {
  const form = useRef(null)
  return (
    <FormContext value={{...defaultProps, requiredTitle: '*'}}>
        <ReactNativeForm .../>
    </FormContext>
  )
}

Form Context Props

{
  theme: {
    primaryColor: string; // Your main theme color. Used for e.g. buttons
    highlightColor: string; // Used for focused inputs, checked checkboxes, slider...
    borderColor: string; // Color of textinput borders
    textColor: string;
    placeholderTextColor: string;
    errorColor: string;
    [propName: string]: any;
  };
  requiredTitle: string;
  arrayAddTitle: string;
  radioLabelMapping?: (label: string) => string;
  [propName: string]: any;
}

Development

  1. Run npm start in root folder to run the dev server
  2. cd example && npm run android to start the example app

react-native-jsonschema-form's People

Contributors

dependabot[bot] avatar mbellagamba avatar zhigang1992 avatar

Stargazers

 avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar

Watchers

 avatar  avatar

react-native-jsonschema-form's Issues

Wrong with enum values

Hi Zhigang,
I am very interested in your project, but when I run it in my project there are some problems.
With the type of property is enums, I would like it view as a dropdown box, but currently its view is a select/option.
Screen Shot 2021-03-13 at 01 08 59
I expect the result to look like the image below
Screen Shot 2021-03-13 at 01 12 07

This is my schema
{ "type": "object", "title": "Daily glucose values", "required": [], "properties": { "azdqamatgu": { "type": "array", "items": { "type": "object", "properties": { "hour": { "enum": ["0", "1", "2"], "type": "string", "title": "hour" }, "minute": { "enum": ["0", "1", "2", "3", "4"], "type": "string", "title": "minute" } } }, "title": "X giờ / lần", "primitive": "default" } } }
Please help me, thank you!

Support for more recent versions @rjsf/core (^4.0.0)

Issue

Currently, this package depends on "@rjsf/core": "^2.0.0". However this is a very old version, and has scary warnings about peer dependencies like:

warning @rjsf/core > [email protected]: core-js@<3.23.3 is no longer maintained and not recommended for usage due to the number of issues. Because of the V8 engine whims, feature detection in old core-js versions could cause a slowdown up to 100x even if nothing is polyfilled. Some versions have web compatibility issues. Please, upgrade your dependencies to the actual version of core-js.

Discussion

It would be good to support the latest version of @rjsf/core.

I feel like this might be a relatively small fix, because from testing against @rjsf/core ^4.0.0, I only get crashes on react-native when my schema uses arrays. Specifically I see:

ReferenceError: Can't find variable: crypto

This error is located at:
    in ArrayField (created by SchemaField)
    ...

So probably @rjsf/core has added a new ArrayField that we need to provide a react-native alternative for (I'm not an expert on how this package works).

Aside: I realise that this is a very niche library that's not actively maintained, so if anyone reading this can point me to an alternative, that would be very useful. I took a look at https://github.com/CareLuLu/react-native-web-jsonschema-form but had trouble getting it working.

Conditionals

Does this library support conditional rendering? I.e. some field A value should render a field B? Thanks for porting this over to Native as well!

Recommend Projects

  • React photo React

    A declarative, efficient, and flexible JavaScript library for building user interfaces.

  • Vue.js photo Vue.js

    🖖 Vue.js is a progressive, incrementally-adoptable JavaScript framework for building UI on the web.

  • Typescript photo Typescript

    TypeScript is a superset of JavaScript that compiles to clean JavaScript output.

  • TensorFlow photo TensorFlow

    An Open Source Machine Learning Framework for Everyone

  • Django photo Django

    The Web framework for perfectionists with deadlines.

  • D3 photo D3

    Bring data to life with SVG, Canvas and HTML. 📊📈🎉

Recommend Topics

  • javascript

    JavaScript (JS) is a lightweight interpreted programming language with first-class functions.

  • web

    Some thing interesting about web. New door for the world.

  • server

    A server is a program made to process requests and deliver data to clients.

  • Machine learning

    Machine learning is a way of modeling and interpreting data that allows a piece of software to respond intelligently.

  • Game

    Some thing interesting about game, make everyone happy.

Recommend Org

  • Facebook photo Facebook

    We are working to build community through open source technology. NB: members must have two-factor auth.

  • Microsoft photo Microsoft

    Open source projects and samples from Microsoft.

  • Google photo Google

    Google ❤️ Open Source for everyone.

  • D3 photo D3

    Data-Driven Documents codes.