I’ve started using React in a new project of mine. I’m used to using autoform for generating and handling forms. However, since now I’ve replaced blaze with React, it seems like I can no longer use autoform.
I’m fine writing out the forms manually (I never used autoform’s quickform anyway). My main concern is handling validation and form submission. In the few examples of Meteor + React that I’ve found, it was always done manually.
Is there any existing package or pattern for efficiently handling forms with React, or can I somehow still use autoform with React?
Here’s a few React form libraries. I haven’t used any of these as my recent project required me to build a custom form set. I ended up building my own component set.
You can install these using the React Meteor guide and Browserify section:
Thanks for the links! I’m new to React so I wasn’t aware of those.
The problem is, I have schemas defined for all of my collections. Those libraries have their own way of defining schemas which aren’t the same syntax, so I can’t re-use the Simple Schema objects.
I don’t want to re-write the schemas because they are used server side as they are now. So I guess I’ll need to make my own implementation that works with Simple Schema.
Unless there is a way to use blaze templates inside or React components? In that case I could still use Autoform, even though it’s kinda hacky.
A combo of React Parts and searching on Github ranked by stars is usually my goto. However even then it’s hard to get some of the gems
[quote="coniel, post:3, topic:7048"]
The problem is, I have schemas defined for all of my collections. Those libraries have their own way of defining schemas which aren't the same syntax, so I can't re-use the Simple Schema objects.
[/quote]
I’m not familiar with the syntax they want but is it possible to run it through a function to convert the names/types to a shape that the component expects? (basically taking the old object and constructing a new one with the old data).
[quote="coniel, post:3, topic:7048"]
Unless there is a way to use blaze templates inside or React components? In that case I could still use Autoform, even though it's kinda hacky.
[/quote]
Yep that’s always an option. Some things I can’t live without, like tabular tables. Here’s an example of the login buttons (i’m sure there might be a React component for this out there already but this is what I have in my prod apps):
```
var LoginButtons = React.createClass({
componentDidMount() {
var div = document.getElementById(‘login-container’);
Blaze.renderWithData(Template.loginButtons, {}, div);
},
// don’t allow this part of the dom update or React may complain
shouldComponentUpdate() {
return false;
},
I just want to call out that we here at MDG are aware of this issue and it’s one of the main things we need to address in the plan for moving to React. We’ll probably need to talk with @aldeed and see how we can refactor some of his work, since right now SimpleSchema is definitely the way to go.
https://github.com/vazco/uniforms/ is an excelent library for form-handling in react with support for simple-schema and graphql-schemas, with default-uis for bootstrap3, 4, semantic ui, antd and material.