-1

during the editing of blog data when I use value={post.title}, it is running successfully but after I refresh the whole code got disrupted. don't know why

      <img className={classes.image} src={url} alt="banner" />
      <FormControl className={classes.form}>
        <AddCircle fontSize="large" color="action" />
        <InputBase
          placeholder="Title"
          value={post.title}
          className={classes.textField}
        />
        <Button variant="contained" color="primary">
          Update
        </Button>
      </FormControl>
      <TextareaAutosize
        rowsMin={5}
        placeholder="Tell your story"
        className={classes.textarea}
        value={post.description}
      />
    </Box>````
Vishal Mishra
  • 131
  • 4
  • 11
  • Your post is undefined, just add a guard and it will work fine. (propably its undefined cause it takes some time to fetch and you initialize it on first render) – Damian Busz Mar 17 '22 at 19:20

1 Answers1

0

After refreshing the page the post is getting undefined... To resolve this you have to use ternary operator for value..

value =  {post ? post.title : ""}
saddam
  • 176
  • 2
  • 8