Component Props Generate Prompt
LangChain Hub prompt: ethanou/component_props_generate_prompt
You will be given a React component code and a new component name. Your task is to identify hard-coded text in the component, extract it as input attributes, update the component name, and rewrite the code in TypeScript. Follow these steps carefully:
- First, you will receive the React component code:
{REACT_COMPONENT}
- You will also receive the new component name:
{NEW_COMPONENT_NAME}
-
Identify all hard-coded text content within the component. This includes any string literals that are not already passed as props or part of JSX attributes. Pay attention to text within JSX elements, default values for variables, and any other string constants.
-
For each piece of hard-coded text you identified, create a new prop in the component's props interface. The prop name should be descriptive and follow camelCase convention. For example, if you find a hard-coded title "Welcome to My App", you might create a prop called "welcomeTitle".
-
Replace all instances of hard-coded text in the component with references to the newly created props. Use the prop names you defined in step 4.
-
Update the component name to the new name provided in tags. Ensure you update both the function name and any references to the component within the code.
-
Rewrite the entire component in TypeScript. This involves:
- Adding type annotations for props, state, and any other variables
- Using interfaces or type aliases to define the shape of objects
- Adding return types to functions
- Ensuring all event handlers have proper TypeScript types
- Only use serializable type as the props fields types, do not use any React ComponentType or ElementType
-
Format your final output as follows:
// Your TypeScript code here
-
After the updated component, list the new props you've created along with their types and descriptions using tags. Format each prop as follows: propName: PropType - Description
Make sure your final output is a fully functional TypeScript React component with all hard-coded text extracted as props, the component name updated, and proper TypeScript annotations added.
How to Use
Use with LangChain: hub.pull("ethanou/component_props_generate_prompt")
Related Prompts
More prompts in Writing & Content
Human Written |100% Unique |SEO Optimised Article
Human Written | Plagiarism Free | SEO Optimized Long-Form Article + Outline & Real-Time Web Search
Fully SEO Optimized Article including FAQ's (2.0)
Create a 100% Unique and SEO Optimized Article | Plagiarism Free Content with | Title | Meta Description | Headings with Proper H1-H6 Tags | up to 2500+ Words Article with FAQs, and Conclusion.
Write Best Article to rank on Google
Write Best Smart Article Best to rank no 1 on Google by just writing Title for required Post. If you like the results then please hit like button.
one click ebook for kids
create an ebook for a childs growth for example rhyme for kids
Yoast SEO Optimized Content Writer
Write detail YoastSEO optimized article by just putting blog title. I need 5 more upvotes so that I can create more prompts. Hit upvote(Like) button.
TopG Cheat Code
This is the TopG CheatCode for ChatGPT 4. Find a long format video on Youtube, copy the link and paste here, then have ChatGPT 4 do the work. For the full tutorial please ATTENTION: For this to work properly you will need to have the following plugin installed: ChatGPT4 Plugin - VideoSummary - Please watch full tutorial if you have any questions - instagram.com/digitaljeff