Skip to content
This repository has been archived by the owner on Apr 6, 2023. It is now read-only.

[RFC] React Native Support #42

Closed
diego3g opened this issue May 17, 2019 · 11 comments
Closed

[RFC] React Native Support #42

diego3g opened this issue May 17, 2019 · 11 comments

Comments

@diego3g
Copy link
Contributor

diego3g commented May 17, 2019

What would you like to be added:

React Native support 馃帀

Why is this needed:

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

Is your enhancement request related to a problem? Please describe.

No.

Additional context

Unform can easily be integrated to React Native TextInput's as these components references also store their value as a prop called _lastNativeText (even in uncontrolled components):

Screen Shot 2019-05-17 at 14 34 33

My worry about this is that React Native has different input types from user, pickers like DatePicker, FilePicker, DocumentPicker probably won't have an API to work with reference.

I think we should discuss more about how to integrate these elements or limit unform responsibilities inside React Native.

@dudusotero
Copy link

But, could we begin some implementation without thinking outside TextInput's?

@diego3g
Copy link
Contributor Author

diego3g commented May 17, 2019

@dudusotero Yeah, support for TextInput can be easily implemented. Maybe someone here can take it and open a PR.

@zaguiini
Copy link
Contributor

I personally don't think we should ship any inputs, only the interfaces to integrate the inputs as the user better desires. Sure, we might ship any logic to work with arrays and stuff, but apart from that everything is pretty much the same. Instead of shipping x components for x platforms, seems more practical/logical to ship only the base logic to implement one.

@italomlp
Copy link
Contributor

I saw this discussion and I think that is not the responsibility of Unform to cares about date picker and other input types. So, my suggestion is to check if Unform is used in react native (or separate the files, like styled-components are), and so, provide properly components. For RN, only provides text Inputs (and Scope and Form too, as wrappers), and if the developer that is using Unform wants a Datepicker in the form, he can use the useField hook to register his own components.
What are your thoughts about this approach?

@zaguiini
Copy link
Contributor

I saw this discussion and I think that is not the responsibility of Unform to cares about date picker and other input types. So, my suggestion is to check if Unform is used in react native (or separate the files, like styled-components are), and so, provide properly components. For RN, only provides text Inputs (and Scope and Form too, as wrappers), and if the developer that is using Unform wants a Datepicker in the form, he can use the useField hook to register his own components.
What are your thoughts about this approach?

That's basically my suggestion :D A good one, I'd say!

@italomlp
Copy link
Contributor

@zaguiini yeah. I mean, I agree with you and guess that it is a good approach to achieve Unform in RN.

@zaguiini
Copy link
Contributor

Not only RN, but for DOM as well. Making it simpler we could cut scope and areas of maintenance. That could be an extensions repository with all the custom inputs and stuff.

@lffg
Copy link
Contributor

lffg commented May 21, 2019

Maybe we can create a monorepo (as Babel and even React.js do) with two initial packages:

  • packages/
    • unform
    • unform-react-native, which extends unform and adds other features.

To use in a React.js project (no breaking changes):

import { Form, Input } from "@rocketseat/unform";

// Do stuff.

And in a React Native project:

import { Form, Input, DatePicker ... } from "@rocketseat/unform-react-native";

// Do stuff.

@dudusotero
Copy link

@lffg or can use something like styled-components do, using import {} from 'styled-components and import {} from 'styled-components/native

@douglaszaltron
Copy link

+1

@diego3g
Copy link
Contributor Author

diego3g commented Feb 13, 2020

Now we have support for React Native: https://unform.dev/guides/react-native

@diego3g diego3g closed this as completed Feb 13, 2020
@diego3g diego3g unpinned this issue Feb 13, 2020
Sign up for free to subscribe to this conversation on GitHub. Already have an account? Sign in.
Projects
None yet
Development

No branches or pull requests

7 participants