Skip to content
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

React-native import #679

Open
boyswan opened this issue Jul 29, 2016 · 2 comments
Open

React-native import #679

boyswan opened this issue Jul 29, 2016 · 2 comments

Comments

@boyswan
Copy link

boyswan commented Jul 29, 2016

I'm pretty new to Swift, so please bare with!

Is it possible with c4 to 'export' as a project (I think with a .framework...?), to be imported into other xcode projects?

I've been referencing Swift -> React Native via this tutorial
http://browniefed.com/blog/react-native-how-to-bridge-a-swift-view/

However am unsure whether C4 can be used like this, or whether it was intended for standalone use only.

@traviskirton
Copy link
Collaborator

Hey boyswan, I haven't had a look at react-native. I'll read through this article tonight and post an answer.

Apologies for the long delay in responding to your question. I was on vacation for a few weeks, and then took some time to get caught up with everything.

@traviskirton
Copy link
Collaborator

From what I see on the tutorial you linked, C4 can be used like this.

We actually suggest building your projects by compiling C4 into a framework, so we're already achieving this step.

The real work is in creating the bindings... i.e. everything that allows you to get to doing this kind of stuff:

import React, { requireNativeComponent, processColor } from 'react-native';
let RNLinearGradient = requireNativeComponent('RNLinearGradientSwift', LinearGradient);
class LinearGradient extends React.Component {
  render() {
    let { colors, ...otherProps } = this.props;
    return <RNLinearGradient {...otherProps} colors={processColor(colors)} />;
  }
}
LinearGradient.propTypes = {
  colors: React.PropTypes.array.isRequired,
  locations: React.PropTypes.array,
}
export default LinearGradient;

I'd love to see C4 working with react native.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

No branches or pull requests

2 participants