-
Notifications
You must be signed in to change notification settings - Fork 40
Description
I spent the last hour trying to get this package to work on react-native. I want to share my findings and hopefully spark a discussion onto where to take it from here.
Setup:
installing with yarn worked, but the moment one tries to pass a schema to the Form the RN app crashes due to dependencies on react-dom. Since the package is compiled to es, it's hard to modify the files. I ended up copying the src folder and modifying package.json to point to src/index. RN is able to compile the src files on the fly. That was my biggest hurdle - so if someone has ideas how to actually link and then just watch the files - then please let me know.
Hunting down issues:
Basically since the containers and the fields are outputting html(or rely on other react libraries that output html) the app crashes. I went ahead and removed all containers and fields from the index.js files. I also modified the FieldTemplate as it outputs a div.
Then I provided my own renderers that output rn code and here is the result:

The way see it - if we want to have this package compatible with React native we have to split it and have formik-json-basic, formik-json-web and formik-json-rn
End users would install formik-json-web or formik-json-rn depending on which platform they are targeting.
There are also some problems with the schema - for example RN doesn't know what a css class is... So the rn renderers have to either ignore those completely or maybe convert those to a style object. And one could pass the style object when initialising the form.
const styles = {
"form-group": {
marginBottom: 20,
},
}