Editmode allows you to turn plain text in your React app

Editmode allows you to turn plain text in your React app

Editmode allows you to turn plain text in your React app into easily inline-editable bits of content that can be managed by anyone with no technical knowledge.

Editmode for React

Editmode allows you to turn plain text in your React app into easily inline-editable bits of content that can be managed by anyone with no technical knowledge.

Installation

Use npm to install Editmode:

npm install editmode-react

or if you prefer yarn:

yarn add editmode-react

Usage

Step 1:

Within your React app, navigate to the index file within your src directory. Import the Editmode wrapper and wrap your App within.

import { Editmode } from "editmode-react";

// 👉 `project_id` can be found in the URL:
// https://editmode.com/projects/{project_id}/chunks

ReactDOM.render(
  <React>
    <Editmode projectId={project_id}>
      <App />
    </Editmode>
  </React>,
  document.getElementById("root")
);

Step 2:

Rendering a chunk:

If you have already created the chunk you would like to render on the Editmode CMS, you can simply pass the identifier as a prop and begin editing. You can provide default content as a fallback should anything go wrong trying to retrieve the data from the API:

import { Chunk } from "editmode-react";

function Example() {
  return (
    <section>
      <Chunk identifier="cnk_321">I have default content</Chunk>
      <Chunk identifier="cnk_123" />
    </section>
  );
}

Alternatively, if you are using one of our text editor plugins and would like to create a new chunk directly from the editor, you may select the piece of text you would like to convert and hit CMD+SHIFT+L if you're on Mac and WIN+SHIFT+L if you're on Windows. (For Visual Studio Code users, you can also hit CMD+SHIFT+P if you're on Mac and WIN+SHIFT+P if you're on Windows to open the command palette, type "Editmode: Create Chunk" and hit enter).

Rendering a chunk collection:

Chunk collections are simply a way to categorise chunks and can be used to render repeatable content. Each collection can contain many properties and each property can hold different types of information.

A good use case example would be creating a "Team Member" collection. It may have Full Name, Title and Headshot properties. Within your React app, you may want to display the name, title and headshot of all your team members (ie all chunks within the Team Member collection). You can do this by passing the chunk collection identifier as a prop to the ChunkCollection component. To render the name, title and headshot for each team member, pass the identifiers for each property as a prop to the ChunkFieldValue component:

import { ChunkCollection, ChunkFieldValue } from "editmode-react";

function Example() {
    return (
    <section className="meet_the_team">
      <ChunkCollection identifier="lst_123" className="team_member">
        <h2><ChunkFieldValue identifier="prop_001" className="name"/><h2>
        <h5><ChunkFieldValue identifier="prop_002" className="title"/></h5>
        <div><ChunkFieldValue identifier="prop_003" className="headshot"/></div>
      </ChunkCollection>
    </section>
    );
}

This will render editable headings containing the name and title and an image containing the headshot for every person in the "Team Member" collection.

Using default chunks array as fallback:

For cases when there's no internet connection but your app is designed to work in offline mode, Editmode supports having an array of default chunks as fallback.

const defaultChunksValue = [
  {"identifier":"cnk_2177d77492a2dead1585","chunk_type":"single_line_text","project_id":"prj_h3Gk3gFVMXbl","branch_id":"d1dWhVyF85Yr","master_branch":true,"content_key":"","content":"This is a single line text!"},
];

function Example() {
  return (
    <section>
      <Editmode projectId="prj_h3Gk3gFVMXbl" defaultChunks={defaultChunksValue}>
        <Chunk identifier="cnk_2177d77492a2dead1585" />
      </Editmode>
    </section>
  );
}
Using variables:

Variables that are created in the Editmode CMS are also supported by passing an object prop as variables.

function Example() {
  return (
    <section>
      <Editmode projectId="prj_h3Gk3gFVMXbl" defaultChunks={defaultChunksValue}>
        <Chunk identifier="cnk_2177d77492a2dead1585" variables={{ "name": "John" }} />
      </Editmode>
    </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.

function Example() {
  return (
    <section>
      <Editmode projectId="prj_h3Gk3gFVMXbl" defaultChunks={defaultChunksValue}>
        <Chunk identifier="cnk_14a3902640051246876f" imageHeight={500} imageWidth={200} />
      </Editmode>
    </section>
  );
}

Sizes passed through imageHeight and imageWidth are in pixels.

Step 3:

You can now edit and save all of the chunks in your React app from within the browser - just add editmode=1 as a query string parameter to the current URL.

Download Details:

Author: editmodelabs

Source Code: https://github.com/editmodelabs/editmode-react-native

react react-native mobile-apps

Bootstrap 5 Complete Course with Examples

Bootstrap 5 Tutorial - Bootstrap 5 Crash Course for Beginners

Nest.JS Tutorial for Beginners

Hello Vue 3: A First Look at Vue 3 and the Composition API

Building a simple Applications with Vue 3

Deno Crash Course: Explore Deno and Create a full REST API with Deno

How to Build a Real-time Chat App with Deno and WebSockets

Convert HTML to Markdown Online

HTML entity encoder decoder Online

How native is React Native? | React Native vs Native App Development

Article covers: How native is react native?, React Native vs (Ionic, Cordova), Similarities and difference between React Native and Native App Development.

React Native Mobile App Development

Skenix is providing React Native Development Services with qualified React Native App Developers. Get the best React Native App Development Services.

How React Native Is Shaping Mobile App Development

Are you a mobile app developer looking for more efficient tools for your projects? Mobile app development is getting tougher and tougher as the market continues to grow. As a developer, you need to develop Apps which meet the demands of your users. To achieve this, adopt the right tools, like the React Native development framework.

Top React Native Mobile App Development Companies in USA

Looking for top React Native mobile app development company in USA for Startups & Enterprise? Find out the top list of React Native mobile app development company in USA.

Which is the best React Native app development company in New York?

Hire top react native app development company in New York to build and develop custom react native mobile apps for Android & iOS with the latest features.