Too many undocumented dependencies
Closed this issue · 3 comments
I tried to use this, but found that it got me into a rat hole of undocumented dependencies. It turns out that this simple-react-form-bootstrap package is built on top of the simple-react-form-material-ui package, which itself has a bunch of dependencies. So I had to manually install:
- moment
- simple-react-form-material-ui
- material-ui
- react-tap-event-plugin
Then I had to update react and react-dom to their 15.4.0-0 versions.
Once I had resolved these dependencies, I got this when trying to render a Form with one Field of type "Text":
9…:4614 Warning: Failed context type: The context
muiThemeis marked as required inTextField, but its value isundefined.
in TextField (created by TextFieldComponent)
in TextFieldComponent (created by Field)
in Field (created by AdminView)
in form (created by Form)
in Form (created by AdminView)
in div (created by AdminView)
in AdminView (created by RouterContext)
in div (created by BasicLayout)
in BasicLayout (created by RouterContext)
in RouterContext (created by Router)
in Router
And also:
TypeError: Cannot read property 'prepareStyles' of undefined
at TextField.render (modules.js?hash=d3491c9…:35490)
at modules.js?hash=d3491c9…:17145
at measureLifeCyclePerf (modules.js?hash=d3491c9…:16424)
(etc.)
I investigated the code, and disovered that "muiTheme" is a material-UI thingy. I thought I was doing Bootstrap, not material-UI!
After spending well more than an hour on this, and be unwilling to learn another UI scheme, I decided that "simple-react-form-bootstrap" is not really simple, and gave up. I'll spend the next 20 minutes backing out these dependencies and try something else to create a simple form.
This is weird, since this package doesn't have any dependency to the material UI one.
The docs are messy and I should provide a better example, since the one that comes in the example is outdated and messy.
I appreciate you giving me your point of view on the matter.
To use this package, you need simple-react-form, which is the foundation of both -bootstrap and -material-ui ones.
Simple React Form (SRF) provides a modular skeleton to build forms. You create a container, <Form>, which holds the state of the form, and some <Field> which provide the visual UI.
simple-react-form-bootstrap provides pre-built Fields. Check out this line which shows how to use a Field with a component from SRF Bootstrap. Here you have a list of all the fields provided by this package.
Hope this helps a little.
Since there's not much documentation, I relied on the simple-react-form-examples package, and apparently was mislead by (for example) line 3 of create.jsx, where it imports "material-ui/RaisedButton". This made me believe that the bootstrap support depended on material-ui.
I think I did not see the simple-react-form-bootstrap-examples package at all. So my suggestion is to update the readme.md file for the simple-react-form package to reference both the bootstrap and the material-ui packages and examples. Currently it references only the material-ui support and I guess my searching for the bootstrap versions missed the bootstrap examples.
I'll try to add docs and better examples this weekend.
Thanks for the feedback!