#9 Try REACTjs Tutorial - Convert Prop to a State

preview_player
Показать описание
#9 Try REACTjs Tutorial - Convert Prop to a State

-----

Рекомендации по теме
Комментарии
Автор

This is just what I was looking for, thanks!

lilianaluna
Автор

componentDidMount() refers to the past which would imply that it is called after render(), whereas componentWillMount() is called before the render

sostomc
Автор

u should look into && operator, also component did mount renders after the render function

Albertmars
Автор

I keep getting : "Objects are not valid as a React child (found: object with keys {title, content}). If you meant to render a collection of children, use an array instead" I ended up changing to post.content which helped until I tried to change title

joshuajean
Автор

Is there an advantage to setting state the way you did as an object and not a function? For example this.setState(() => ({postItem:post})); For me maybe not for this app but if I was doing an api call and then passing the props down to a child or grandchild component the Async delay would cause it to error. When I did it as a function I avoided that error. Obviously I would use componentDidUpdate to check that the props were not null but the function method just seemed to work better. I’m learning react so any insight would be helpful.

OneBrighDay
Автор

Just curious, couldn't we set const{post} = this.props in the constructor? to avoid having it set to null?

YeetusDeletus
Автор

u never explain what 'this' does, after much research i believe that 'this', references the current object. these r gd tutorials, but i find that u don't always explain all of the built in functions you r using

yadude
join shbcf.ru