Shows using a basic frame with React Native Web.
» Download ReactNativeDemo.framerfx.zip
Not suitable for production use until the following issues are fixed:
- Framer bundles the "react-dom" module without the "react-dom/unstable-native-dependencies" module. This can partially be worked around by installing "react-dom" into the project locally, but Framer will revert to using the built-in one regularly and the canvas or preview will need to be reloaded.
Getting the project setup is relatively simple:
- Create a new Framer project
- From the menubar choose File > Show Project Folder (or ⌘⌥P)
- From the menubar choose Finder > Services > New Terminal at Folder
- Run the following
yarn add react react-dom @types/react-native react-native@npm:react-native-web
*
* This will alias react-native-web -> react-native without needing a WebPack config.
Then create a new code file in Framer called App.tsx and paste the following:
import * as React from "react"
import { Frame, addPropertyControls, ControlType } from "framer"
import { View, Text } from "react-native"
class App extends React.Component<{ text: string; background: string }> {
static defaultProps = { text: "Hello World", background: "#44bb44" }
render() {
return (
<View
style={{
flex: 1,
alignItems: "center",
justifyContent: "center",
backgroundColor: this.props.background,
height: "100%",
}}
>
<View>
<Text style={{ color: "#ffffff" }}>{this.props.text}</Text>
</View>
</View>
)
}
}
export const FramerApp: React.FC<{
text: string
background: string
}> = props => (
<Frame size="100%">
<App {...props} />
</Frame>
)
addPropertyControls(FramerApp, {
text: {
type: ControlType.String,
defaultValue: App.defaultProps.text,
title: "Text",
},
background: {
type: ControlType.Color,
defaultValue: App.defaultProps.background,
title: "Background",
},
})
When previewed this will give you a very basic React Native component containing a green frame and the text "Hello World" with custom controls that allow configuration of the text and background color.