Hello community, I hope all is well?
I’m stuck on the passing thoughts React project, on task 6. I’ve followed the hints, and video but must be missing something. Basically I should be able to enter a thought it just renders as “object object”? Please can someone advise or shed some light on what I’m missing?
Thanks in advance,
Cy
App.js
import React, { useState } from “react”;
import ReactDOM from “react-dom”;
import { AddThoughtForm } from “./AddThoughtForm”;
import { Thought } from “./Thought”;
import { generateId, getNewExpirationTime } from “./utilities”;
export default function App() {
const [thoughts, setThoughts] = useState([
{
id: generateId(),
text: “This is a place for your passing thoughts.”,
expiresAt: getNewExpirationTime(),
},
{
id: generateId(),
text: “They’ll be removed after 15 seconds.”,
expiresAt: getNewExpirationTime(),
},
]);
const addThought = () => {
setThoughts((thoughts) => [thought, …thoughts]);
};
return (
Passing Thoughts
{thoughts.map((thought) => (
))}
);
}
AddThoughtForm.js
mport React, { useState } from “react”;
import { generateId, getNewExpirationTime } from “./utilities”;
export function AddThoughtForm(props) {
const [text, setText] = useState(“”);
const handleTextChange = ({ target }) => {
const value = {target};
setText(value);
};
const handleSubmit = (event) => {
event.preventDefault();
const thought = {
id: generateId(),
text: text,
expiresAt: getNewExpirationTime(),
};
props.addthought(thought);
};
return (
);
}
Thought.js
import React from ‘react’;
export function Thought(props) {
const { thought, removeThought } = props;
const handleRemoveClick = () => {
removeThought(thought.id);
};
return (
×
);
}
Utilities.js
export function getNewExpirationTime() {
return Date.now() + 15 * 1000;
}
let nextId = 0;
export function generateId() {
const result = nextId;
nextId += 1;
return result;
}