Business
Jobs
  • About Us
  • Solutions
    • Job Postings
      Post your job and receive qualified candidates in 48h.
    • Candidate Assessments
      500+ technical and psychological tests, plus anti-fraud.
    • Headhunting
      Tailor-made executive search from start to finish.
    • Payroll + EOR
      Payroll dispersal and EOR across 15+ LATAM countries.
  • Pricing
  • Jobs

0

147
Views
Passing variable into JSX HTML Attribute

How can I pass a variable into the attribute. I am using: https://polaris.shopify.com/components/actions/button

I currently have

  const subscribeButton = (plan, text, type) => (
    <div style={{textAlign: 'center', 'paddingBottom': 15}}>
      <Button
        onClick={() => processSubscription(plan.stripe_price_id)}
        key={plan.stripe_plan_id}
       -> Need to insert "type" here <-
      >
        <p>{text}</p>
      </Button>
    </div>
  )

In my render, I have a few of these

subscribeButton(plan, 'Cancel', 'destructive')

I need pass the type of button, "primary", "destructive" and a few more options. I pass that in with the 3rd param. The issue is, this is a dynamic field such as

<Button primary></Button> and <Button destructive>.

How would I go about passing this in via a variable?

about 4 years ago · Juan Pablo Isaza
Answer question
Find remote jobs

Discover the new way to find a job!

Top jobs
Top job categories
Business
Post vacancy Pricing Sales
Legal
Terms and conditions Privacy policy
© 2026 PeakU Inc. All Rights Reserved.
Andres GPT
Show me some job opportunities
There's an error!