# Cosmos DX Component for the React Naïve

**URL:** <https://forums.pega.com/t/cosmos-dx-component-for-the-react-naive/3319>\
**Category:** Knowledge Share\
**Tags:** 8-7, user-experience, constellation\
**Created:** [October 6, 2022, 1:51pm UTC](https://forums.pega.com/t/cosmos-dx-component-for-the-react-naive/3319 "2022-10-06T13:51:10Z")\
**Posts on this page:** 1\
**Page:** 1

<div class="post-metadata">

**Author:** ![KAUSTAV.DUTTA](https://yyz2.discourse-cdn.com/pega/user_avatar/forums.pega.com/kaustav.dutta/32/7195_2.png) [@KAUSTAV.DUTTA](https://forums.pega.com/u/KAUSTAV.DUTTA)\
**Post date:** [October 6, 2022, 1:51pm UTC](https://forums.pega.com/t/cosmos-dx-component-for-the-react-naive/3319/1 "2022-10-06T13:51:10Z")

</div>

Well first let me start by saying that this article is mostly intended for the Pega developer who is just starting out on the journey of leveraging cosmos react components and wants to create a component based on the instructions from [design.pega.com](http://design.pega.com).

It’s also for the Lead Architects who I believe in the future would be working with professional front end developers for them I think it makes sense to know the basics.

While the [design.pega.com](http://design.pega.com) provides sample code it does assume that the user has some experience with react and some minor tweaks are necessary to create a working component from the sample code.

So, in this article I will try to simplify this so that a developer with minimal experience in react can leverage the sample code to create a working component. We will use the CreditCard component as an example since it’s defined in the design system but not available OOTB in 8.7.

We will follow a 3-step process

**Step 1 - Create Cosmos digital experience (DX) component**

For this follow the instructions available at [Cosmos DX components in Cosmos React | Pega](https://docs-previous.pega.com/cosmos-dx-components-cosmos-react/87/cosmos-dx-components-cosmos-react) or the excellent article at [Video: steps to create a Cosmos DX component | Support Center (pega.com)](https://support.pega.com/discussion/video-steps-create-cosmos-dx-component)

Use Type = Field and Subtype = text / integer

Here’s a short demo of what I did

![Create Component.gif](https://pega1.discourse-cdn.com/pega/original/2X/1/142b636ee713e90e2d011a1fe5304dce9bf78d37.gif)

**Step 2 - Update the JSX in the Return block**

- Open the index.jsx file inside the src\components folder.
- Go to [design.pega.com](http://design.pega.com) and copy the JSX (from the return block)
- Delete the existing JSX from the return code block in the index.jsx file

Paste the copied JSX in the return block of the index.jsx file

![Update JSX.gif](https://pega1.discourse-cdn.com/pega/original/2X/3/34cddbd68b5f139c523214fe219ffe977e35802b.gif)

**Step 3 - This is key** , **update the Import statement** at the top of the index.jsx file **and the Event Handler section** of the index.jsx file.

![Update Import and Event Handler.gif](https://pega1.discourse-cdn.com/pega/original/2X/6/656a227081f8d9a66142fbdff1e070a256880d12.gif)

**And that’s all now it’s time to test**

![Testing.gif](https://pega1.discourse-cdn.com/pega/original/2X/3/3e7ff376ba441774ac016e1e99d99206f630426f.gif)

Now **push the code to Pega** and use the component for that follow the article at [Publishing Cosmos DX components | Pega](https://docs-previous.pega.com/cosmos-dx-components-cosmos-react/87/publishing-cosmos-dx-components)

I’ve attached the sample index.jsx file for reference
