gcanti / tcomb-form

Forms library for react
https://gcanti.github.io/tcomb-form
MIT License
1.16k stars 136 forks source link

Error on a simple test #199

Closed hhumphrey84 closed 9 years ago

hhumphrey84 commented 9 years ago

I've created a simple test in my app in an attempt to start using tcomb-form to handle my forms and I'm coming against an error:

Error: Invariant Violation: Form.render()

My code is as below:

import React from 'react';
import PlayerActions from '../actions/PlayerActions';
import PlayerStore from '../stores/PlayerStore';
import t from 'tcomb-form';

const Person = t.struct({
  name: t.Str
});

class PlayerAdd extends React.Component {

    render() {

        return (
            <form>

          <t.form.Form 
            ref='form'
            type={Person} />

                <button type='submit' className='btn btn-primary'>Submit</button>
            </form>
        )
    }
}

export default PlayerAdd;

Any ideas as to what might be happening / what I've done wrong?

Thanks, Helen

gcanti commented 9 years ago

Just tried your code and it works for me. Could you please post which version of react and tcomb-form you are using and the exact error message?

hhumphrey84 commented 9 years ago

Thanks for your swift reply, I'm using version 0.13.3 of react and 0.7.1 of tcomb-form.

On Mon, Sep 14, 2015 at 6:12 PM, Giulio Canti notifications@github.com wrote:

Just tried your code and it works for me. Could you please post which version of react and tcomb-form you are using and the exact error message?

— Reply to this email directly or view it on GitHub https://github.com/gcanti/tcomb-form/issues/199#issuecomment-140147341.

gcanti commented 9 years ago

Ok then I think the problem could be a double import of the react library: tcomb-form v0.7.1 requires react v0.14.0-rc1 while you are using react 0.13.3. Probably you are importing 2 different copies of react. Try to install tcomb-form v0.6.4 which is compatible with react 0.13.3

hhumphrey84 commented 9 years ago

Worked a charm. Thank you! I knew it would be simple and now I get to have fun with your great library. Thanks again

On Mon, Sep 14, 2015 at 9:06 PM, Giulio Canti notifications@github.com wrote:

Ok then I think the problem could be a double import of the react library: tcomb-form v0.7.1 requires react v0.14.0-rc1 while you are using react 0.13.3. Probably you are importing 2 different copies of react. Try to install tcomb-form v0.6.4 which is compatible with react 0.13.3

— Reply to this email directly or view it on GitHub https://github.com/gcanti/tcomb-form/issues/199#issuecomment-140191456.

gcanti commented 9 years ago

Great. Happy hacking :+1:

kiki-le-singe commented 9 years ago

@gcanti Great! It works :) thanks