In order to render app copy, you'll need to wrap it in the <Chunk /> component.
The most basic way to render content is to pass in the identifier of your chunk on the Editmode platform.
import { Chunk } from "editmode-react-native";
function Example() {
return (
<section>
<Chunk identifier="cnk_b6d6754b2cf6c59a7847" />
</section>
);
}
For better readability, you can opt to pass in the content key of your chunk on the Editmode platform.
import { Chunk } from "editmode-react-native";
function Example() {
return (
<section>
<Chunk contentKey="simple_chunk_example" />
</section>
);
}
Use variables to personalize and interpolate the content you're showing.
import { Chunk } from "editmode-react-native";
function Example() {
return (
<section>
<Chunk contentKey="welcome_message" variables={{first_name:"Joe"}} />
</section>
);
}
Fallbacks
As you may have inferred, the above examples rely on the Editmode API to serve content. This carries speed and uptime considerations. To address this, you may also specify your own fallback content, in a number of ways.
Using a resource file
import { defaultChunks } from "./data/defaultChunks";
import { Chunk } from "editmode-react-native";
function Example() {
return (
<Editmode projectId={project_id} defaultChunks={defaultChunks} >
<section>
{/* The following chunk will first check the content in defaultChunks before hitting the API. */}
<Chunk identifier="cnk_b6d6754b2cf6c59a7847" />
</section>
</Editmode>
);
}
Want to automate your tooling or workflow and generate your resource file programatically? You can use the content returned from the GET Chunks API endpoint.
Specifying default content inline
import { Chunk } from "editmode-react-native";
function Example() {
return (
<section>
{/* The following chunk show the inline content before fetching content from our API. */}
<Chunk contentKey="welcome_message">Welcome to our app!</Chunk>
</section>
);
}
Adding custom width and height to images
By default every image rendered using Editmode is sized 50px in height and 50px in width. You can override those sizes by passing imageHeight and imageWidth as props.
Sizes passed through imageHeight and imageWidth are in pixels.
Trigger Cache Expire
You may want to refresh all your contents to make sure your user see the right contents in your app. You can use the refreshChunks function to force update your local storage with the recent version of your contents from Editmode Content Hub.