dotCMS / dotCMS/core

Implement "Contentlet" component in React SDK

Open
#31,932 1 comment 0 reactions 0 assignees View on GitHub

Nobody has claimed this yet.

Team : Scout Type : Task
Dominant language
Java
Stars
970
Forks
486
Avg merge
3d 33m
Merged PRs (30d)
170

Description

Task

Implement a wrapper to render and listen changes about Contentlets out the DotCMSPageBody component

import { createUVESubscription } from '@dotcms/uve';

function Contentlet({ children, Contentlet: contentlet }) {
    const [newContentlet, setNewContentlet] = useState(contentlet);

    useEffect(() => {
        const { unsubscribe } = createUVESubscription(
            `contentlet_change:${contentlet.identifier}`,
            (payload) => {
                // This will only trigger if the contentlet with that identifier has changed
                setNewContentlet(payload);
            }
        );

        return () => unsubscribe();
    }, [contentlet]);

    const newChildren = useMemo(() => {
        return children.map((child) => {
            return React.cloneElement(child, { contentlet: newContentlet });
        });
    }, [children, newContentlet]);

    return <div>{newChildren}</div>;
}

export default Contentlet;
Proposed Objective

Technical User Experience

Proposed Priority

Priority 2 - Important

Acceptance Criteria
  • The component can render Contentlets outside PageBody component.
  • The component can be editable in UVE
  • The component only re-render when the contentlet have changes
  • The component have a simple API to integrate to customer projects
Sub-Tasks & Estimates
  • [ ] Create a new event like "contentlet-changes"
  • [ ] Create a component "Contentlet" to render contentelts outside DotCMSPagebody, including the data-attr
  • [ ] Subscribe the component Contentlet to contentlet-changes and re-render only when the appropiate contentlet have changes

Contributor guide

Open the contributing guide

First steps

  1. Read the whole issue, then the project's contributing guide.
  2. Comment on the issue to say you are picking it up — it saves two people doing the same work.
  3. Fork the repository and make your change on a branch.
  4. Open a pull request that references the issue number.

Research direction

Start by locating the React SDK's DotCMSPageBody implementation and existing @dotcms/uve createUVESubscription usage. Define the Contentlet API and event flow from the task, then verify that contentlets render outside PageBody, remain editable in UVE, and re-render only for the changed identifier.

Written by the indexing model from the issue text.

Assessment

Tech stack
javascript, react
Domain
frontend
Issue type
Feature
Difficulty
4/5
Estimated time
3-5 days
Activity status
Stale
Clarity
Mostly clear
Newbie friendliness
45/100

Get new issues in your inbox

A short digest of beginner-friendly GitHub issues.