Skip to main content
Version: Next

Components API

This section details the API for all Formio components supported by formio-react-native.

FormioForm

The primary component for rendering Form.io forms.

Props

Prop NameTypeDefaultDescription
formFormioFormSchemarequiredThe Form.io form schema JSON.
dataobject{}Initial submission data for the form.
optionsFormioOptions{}Configuration options for the form renderer.
onSubmit(submission: any) => voidundefinedCallback function when the form is submitted.
onChange(component: any, value: any) => voidundefinedCallback function when any component's value changes.
onError(errors: FormioError[]) => voidundefinedCallback function when form validation errors occur.
i18nobject{}Custom internationalization messages.
themestring'default'Name of the theme to apply.
childrenReactNodeundefinedCustom children to render inside the form.

Usage Example

import React, { useState } from 'react';
import { View, Alert } from 'react-native';
import { FormioForm } from 'formio-react-native';

const myForm = {
components: [
{
type: 'textfield',
key: 'name',
label: 'Your Name',
validate: { required: true },
},
{
type: 'email',
key: 'email',
label: 'Your Email',
validate: { required: true, email: true },
},
{
type: 'button',
action: 'submit',
label: 'Submit Form',
},
],
};

function MyFormWrapper() {
const [submissionData, setSubmissionData] = useState({});

const handleSubmit = (submission: any) => {
Alert.alert('Form Submitted', JSON.stringify(submission, null, 2));
setSubmissionData(submission);
};

const handleChange = (component: any, value: any) => {
console.log(`Component '${component.key}' changed to:`, value);
};

const handleError = (errors: any[]) => {
console.error('Form errors:', errors);
// Display errors to the user
};

return (
<View style={{ flex: 1, padding: 20 }}>
<FormioForm
form={myForm}
submission={submissionData}
onSubmit={handleSubmit}
onChange={handleChange}
onError={handleError}
/>
</View>
);
}

export default MyFormWrapper;

Next: Core APIs