Skip to content
This repository has been archived by the owner on Jan 27, 2022. It is now read-only.
Alex van den Oudenhoven edited this page May 12, 2021 · 4 revisions

Welcome to the jform-react wiki!

This package is a updated TypeScript rewrite of liform-react and can be used as a drop-in upgrade/replacement

Installation

npm install jform-react --save 

Basic Usage

import React from 'react';
import ReactDOM from 'react-dom';

import { createStore, combineReducers } from 'redux';
import { reducer as formReducer } from 'redux-form';
import { Provider } from 'react-redux';
import Jform from 'jform-react';


const reducer = combineReducers({
  form: formReducer
})

var schema = {
  "title": "Some form",
  "properties": {
    "name": { "type":"string","title":"Model", "default": "Ziummmm"},
    "description": { "type":"string", "title": "Description", "widget": "textarea" }
  },
  "required": ["name"]
};

const store = (window.devToolsExtension ? window.devToolsExtension()(createStore) : createStore)(reducer)

const showResults = values => {
    window.alert(`You submitted:\n\n${JSON.stringify(values, null, 2)}`)
}

const dest = document.getElementById('form-holder')

ReactDOM.render(
    <Provider store={store}>
        <Jform schema={schema} onSubmit={showResults}/>
    </Provider>,
    dest
)

Version Support

Dependency Version
Node.js LTS 14.16.1 LTS
Ajv >=8.3.0
React 16
Clone this wiki locally