This is a list of short and useful Framer X tips to build impressive prototypes.
- How to share data between components using override?
- How to detect if a component has children nodes?
- How to import JSON files with data?
- How to use a design component structure inside your code component?
- How to wrap an installed component with your code component?
- How to use REST API inside a code component?
- How to use GraphQL API inside a code component?
- How to install an npm package?
import { Data, Override } from "framer"
const data = Data({
text: "Overview",
})
export const TextChange: Override = props => {
return {
onValueChange: (text: string) => {
data.text = text
}
}
}
export const GetText: Override = el => {
let page = 0
if (data.text == "Overview") page = 1
if (data.text == "Interaction") page = 2
return {
page: page,
}
}
const hasChildren = (children: React.ReactNode) =>
!!React.Children.count(children);
// Add the follow code in tsconfig.json file
"compilerOptions": {
...
"resolveJsonModule:" true
}
import { componentName } from './canvas';
import { Component } from '@framer/componentname/code/File.js'
static defaultProps = {
...Component.defaultProps,
}
// Reuse the propertyControls from the imported component
static propertyControls: PropertyControls = {
...Component.propertyControls,
}
render() {
return <Component {...this.props}>
}
loadData = async () => {
const url = "http://url"
const result = await fetch(url)
const result = await result.json()
this.setState({ result })
}
componentDidMount = () => {
this.loadData();
};
import { request } from 'graphql-request'
loadData = async () => {
const url = "http://url"
const query =`
{
query {
fields
}
}
`
const result = await request(url, query)
this.setState({ result })
}
componentDidMount = () => {
this.loadData();
};
- File > Show Project Folder
- Open the path in terminal and install the the package