-
Notifications
You must be signed in to change notification settings - Fork 28
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
Expo.io integration #18
Comments
I see. Here's the implementation of makeReactNativeDriver: function makeReactNativeDriver(appKey) {
return function reactNativeDriver(sink) {
const source = new ReactSource()
const Root = makeCycleReactComponent(() => ({source, sink}))
AppRegistry.registerComponent(appKey, () => Root)
return source
}
} So it's quite simple. I think in Expo you could just use Then you can export the App component. If this solution works, let me know how exactly you did it. We could update the README with instructions for other people. |
I tested both functions, Everything is displayed properly but click event can not be captured. If I use the event stream generated by import xs from 'xstream';
import {TouchableOpacity, View, Text } from '@cycle/react-native';
import {setup} from '@cycle/run';
import { makeCycleReactComponent, makeComponent, ReactSource } from '@cycle/react'
import { AppRegistry } from 'react-native'
function main(sources) {
const inc = Symbol();
// It does NOT work on neither version, no event is captured
const inc$ = sources.react.select(inc).events('click');
// It works on both versions
//const inc$ = xs.periodic(1000)
const count$ = inc$.fold(count => count + 1, 0);
const elem$ = count$.map(i => TouchableOpacity(inc, [
View([
Text(`Counter: ${i}`)
])
])
);
return {
react: elem$,
};
}
// Version 1
const reactDriver = (sink) => new ReactSource()
const App = makeComponent(main, {react: reactDriver});
// Version 2
/*const App = makeCycleReactComponent(() => {
debugger
const reactDriver = (sink) => new ReactSource();
const program = setup(main, {react: reactDriver});
const source = program.sources.react;
const sink = program.sinks.react;
const events = {...program.sinks};
delete events.react;
for (let name in events) if (name in drivers) delete events[name];
const dispose = program.run();
return {source, sink, events, dispose};
});*/
export default App; |
Try const App = makeComponent(main); not const App = makeComponent(main, {react: reactDriver}); |
I also tried: const App = makeComponent(main); I got exactly the same result. |
What if |
@mihaimodiga Did it work? |
@staltz no, it din't worked with |
@staltz It seems it was a problem with my computer . I assume that Windows firewall blocked some ports. I will investigate more. I switched to Linux and it runs in browser even with import {makeComponent} from '@cycle/react';
// Example Code
const App = makeComponent(main);
export default App; However when I try to run on device, I got the following error: |
Probably right! We should remove the deprecated components |
Besides |
From |
I noticed that the 'click' event was not identified because I used I just uninstalled everything and that I installed just Now it works as expected! |
@mihaimodiga thanks a lot, I can confirm everything you said above, happened to me as well on a fresh project. (every step) I tried and @cycle/react's max compatible version is 1.4.0, from 2.0.0 the clicks do not work as stated above. |
Expo expects App function (that returns react native components) to be the default export. This is prevents the usage of makeReactNativeDriver function as usual.
The text was updated successfully, but these errors were encountered: