final-form / react-final-form-hooks

React Hooks to bind to 🏁 Final Form's high performance subscription-based form state management engine
MIT License
471 stars 19 forks source link

[RFC] React Native Support #48

Closed douglaszaltron closed 3 years ago

douglaszaltron commented 5 years ago

Are you submitting a bug report or a feature request?

feature request React Native support 🎉

Why is this needed:

Currently, Final form only works with web projects using ReactJS but a port to React Native could be created.

superandrew commented 5 years ago

+1

ikismail commented 5 years ago

+1

saczuac commented 4 years ago

+1

souravj96 commented 4 years ago

I'm using this solution to react native and it works fine for me.

import React from 'react';
import { Form, Field } from 'react-final-form';
import createDecorator from 'final-form-focus'

import { View, Input, Button, Text } from 'react-native';

let focusOnError = createDecorator()

class MyScreen extends React.Component {

    validate = function (values) {
        const errors = {};
        alert(JSON.stringify(values))
        return errors
    }

    handleSubmit = function (values) {
        alert(JSON.stringify(values))
    }
    render() {
        return (
            <Form onSubmit={this.handleSubmit}
                decorators={[focusOnError]}
                validate={(values) => { return this.validate(values) }}
                render={({ handleSubmit, submitting, valid }) => (
                    <View>
                        <Field
                            name="FieldName"
                            placeholder="your placeholder"
                        >
                            {({ input, meta, placeholder }) => {
                                let showToolTip = false
                                if (meta.error && meta.visited && !meta.active) {
                                    showToolTip = true
                                }
                                else {
                                    showToolTip = false
                                }
                                return (
                                    <View>
                                        <Input placeholder={placeholder} {...input} />
                                        <Text size={8}>{meta.error}</Text>
                                    </View>
                                )
                            }}
                        </Field>
                        <Button color="info" round={true} size="small" onPress={handleSubmit}>Submit</Button>
                    </View>
                )
                }
            />
        )
    }
}
export default MyScreen
nicklaros commented 4 years ago

@souravj96 I use your code above in typescript project and it spit out a lot of typing error

for example:

Types of property 'onBlur' are incompatible.
        Type '(event?: FocusEvent<HTMLElement>) => void' is not assignable to type '(e: NativeSyntheticEvent<TextInputFocusEventData>) => void'.ts(2769)
souravj96 commented 4 years ago

@souravj96 I use your code above in typescript project and it spit out a lot of typing error

for example:

Types of property 'onBlur' are incompatible.
        Type '(event?: FocusEvent<HTMLElement>) => void' is not assignable to type '(e: NativeSyntheticEvent<TextInputFocusEventData>) => void'.ts(2769)

try to add this line delete input["onBlur"]; after let showToolTip = false

hope it will work.

ianqueue commented 4 years ago

Any new developments here? I see mentioning of React Native in the codebase, but no documentation on it's support. For example Formik has a page on it's use in React Native here https://jaredpalmer.com/formik/docs/guides/react-native#the-gist

santaclauze commented 4 years ago

I am interested to know what is happening with this too

jeanlambert17 commented 4 years ago

Any update?

jafar-jabr commented 2 years ago

any update in 2022 ? :))

fondue-tech commented 1 year ago

Any update in 2023?

omerman commented 1 year ago

This lib is not maintained.. See the last commit 🥲