tcomb-form-native: React Native Hot Reload breaks tcomb-form-native

Version

  • tcomb-form-native: 0.4.0
  • react-native: 0.22.0-rc4

Expected behaviour

React Native 0.22 introduces Hot Reload and after a code change the hot reload behaviour should not break the plugin.

Actual behaviour

After a code change the plugin throws an error.

Steps to reproduce

  1. New react native project
  2. Add a tcomb-form-native form
  3. Enabled Hot Reload in the app
  4. Make a change while the app is running

Stack trace and console log

The error that is thrown: [tcomb][tcomb-form-native] missing stylesheet config

Additional information

  • The error is thrown in the Form.render method by the assert
  • The stylesheet variable is indeed undefined after a code change
  • The other asserts fail as well (templates and i18n)
  • Hot Reload works by wrapping components with a shell that can reloads its component, so somehow the assignments in the index.js file are ignored

About this issue

  • Original URL
  • State: closed
  • Created 8 years ago
  • Reactions: 11
  • Comments: 44 (23 by maintainers)

Commits related to this issue

Most upvoted comments

For those on the same low level as I am, it seems that the import implementation:

var t = require('tcomb-form-native')
var Form = t.form.Form

does not work as of 0.4.3

Hey guys, is everything ok now?

Sorry @alvaromb, the wrong export was my fault.

@sirwoetang I’m also having that problem “Cannot read property ‘Form’ of undefined”

I can check if moving from require to import solves the HMR issue, and then we could slowly start to move to ES6.

Enviado desde mi iPhone

El 25 mar 2016, a las 10:48, Giulio Canti notifications@github.com escribió:

@alvaromb since I wrote the first version of tcomb-form-native, ES6 support has improved. AFAIK we could move:

var -> const and let require -> import module.exports -> export and export default anything else?

— You are receiving this because you were mentioned. Reply to this email directly or view it on GitHub

@gcanti works as a charm, hot reload and all 👍

v0.4.4 released

@alvaromb if that fix works and is really backward compatible (as I hope) I’d say no

Sorry guys I have two important deadlines this week, will try to work on this ASAP.