ManuelDeLeon / viewmodel-react

Create your React components with view models.
MIT License
24 stars 3 forks source link

Allow React Native #13

Closed ManuelDeLeon closed 7 years ago

ManuelDeLeon commented 7 years ago

Right now react-dom is a hard dependency. If it's require('react-dom')'d then ViewModel should work with React Native.

That's the theory at least...

iwasaki-kenta commented 7 years ago

Definitely want to push for it.

ManuelDeLeon commented 7 years ago

All systems are GO...

import { Text } from 'react-native';

Test({
  render(){
    <Text>Hello from ViewModel!</Text>
  }
})

image

Pick up v1.0.1 and be sure to import "babel-polyfill"; on index.android.js and index.ios.js

ManuelDeLeon commented 7 years ago

Just to be clear, most bindings won't work on native components so you need to wire them manually:

Example({
  checked: true,
  render() {
    <CheckBox
      label='Label'
      checked={ this.checked() }
      onChange={ (checked) => this.checked(checked) }
    />
  }
});
iwasaki-kenta commented 7 years ago

So far it seems that say for example with:

Example({
  checked: true,
  render() {
    <CheckBox
      label='Label'
      checked={ this.checked() }
      onChange={ (checked) => this.checked(checked) }
    />
  }
});

I have to export it out: export default Example; or else I'd get an error when passing it around stating object is not a class, from a string, etc.... Could it be as a result of my project being configured incorrectly, or something preventing VM from generating the exports?

ManuelDeLeon commented 7 years ago

import { Example } from './Example/Example';

ManuelDeLeon commented 7 years ago

It doesn't export the class as default.

iwasaki-kenta commented 7 years ago

Alright, thanks :).

ManuelDeLeon commented 7 years ago

I forgot to mention, you can still use "if" and "repeat" bindings because they happen at compile time. So is perfectly valid.

On Thu, Oct 27, 2016 at 1:32 PM, Kenta Iwasaki notifications@github.com wrote:

Alright, thanks :).

— You are receiving this because you modified the open/close state. Reply to this email directly, view it on GitHub https://github.com/ManuelDeLeon/viewmodel-react/issues/13#issuecomment-256745826, or mute the thread https://github.com/notifications/unsubscribe-auth/AED31ngaxUB3Qmx0ji7E1erpb-WUteIyks5q4PxUgaJpZM4KTPNK .