Welcome!

By registering with us, you'll be able to discuss, share and private message with other members of our community.

SignUp Now!
  • Guest, before posting your code please take these rules into consideration:
    • It is required to use our BBCode feature to display your code. While within the editor click < / > or >_ and place your code within the BB Code prompt. This helps others with finding a solution by making it easier to read and easier to copy.
    • You can also use markdown to share your code. When using markdown your code will be automatically converted to BBCode. For help with markdown check out the markdown guide.
    • Don't share a wall of code. All we want is the problem area, the code related to your issue.


    To learn more about how to use our BBCode feature, please click here.

    Thank you, Code Forum.

Date not passed via props in react js

shivajikobardan

Legendary Coder
App.js

JavaScript:
import './App.css';
import Subscription from './components/Subscription';
// import Myroutes from "./Myroutes.js";

function App() {
  let subscriptions = [{ id: "1", date: new Date("2021", "3", "23"), title: "Monthly Subscription", amount: "125.60" },
  { id: "2", date: new Date("2020", "06", "28"), title: "Annual Subscription", amount: "1125.60" },
  { id: "1", date: new Date("2021", "09", "05"), title: "Quarterly Subscription", amount: "425.60" }]

  return (
    <>
      <div className='App'>
        <Subscription datePassed={subscriptions[0].date.toISOString} titlePassed={subscriptions[0].title} amountPassed={subscriptions[0].amount} />
        <Subscription datePassed={subscriptions[1].date.toISOString} titlePassed={subscriptions[1].title} amountPassed={subscriptions[1].amount} />
        <Subscription datePassed={subscriptions[2].date.toISOString} titlePassed={subscriptions[2].title} amountPassed={subscriptions[2].amount} />
      </div>
    </>
  )
};

export default App;

Subscription.js

JavaScript:
import React from 'react'
import "./Subscription.css"
function Subscription(props) {
  return (
    <>
      <div>{props.datePassed}</div>
      <h2 className="subscription-title">{props.titlePassed}</h2>
      <div>{props.amountPassed}</div>
    </>)
}

export default Subscription

Currrent Output that I'm getting:
1672147338777-png.319394

Expected Output:
I need date to come at the top of each of them.
 

Buy us a coffee!

Back
Top Bottom