Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Noticed link wasn't being updated. Bug? #33

Open
mhui opened this issue Dec 1, 2020 · 1 comment
Open

Noticed link wasn't being updated. Bug? #33

mhui opened this issue Dec 1, 2020 · 1 comment

Comments

@mhui
Copy link

mhui commented Dec 1, 2020

I noticed in a list of link previews that the latest item in the list wouldn't have the updated url

is this right? doesn't componentDidUpdate get previous props instead of next props?

 componentDidUpdate(nextProps) {
    if (nextProps.text !== this.props.text) {
      this.getPreview(nextProps.text);
    } else if (nextProps.text == null) {
      this.setState({isUri: false});
    }
  }

this works

 componentDidUpdate(prevProps) {
    if (prevProps.text !== this.props.text) {
      this.getPreview(this.props.text);
    } else if (this.props.text == null) {
      this.setState({isUri: false});
    }
  }
@maherzaidoune
Copy link
Owner

I noticed in a list of link previews that the latest item in the list wouldn't have the updated url

is this right? doesn't componentDidUpdate get previous props instead of next props?

 componentDidUpdate(nextProps) {
    if (nextProps.text !== this.props.text) {
      this.getPreview(nextProps.text);
    } else if (nextProps.text == null) {
      this.setState({isUri: false});
    }
  }

this works

 componentDidUpdate(prevProps) {
    if (prevProps.text !== this.props.text) {
      this.getPreview(this.props.text);
    } else if (this.props.text == null) {
      this.setState({isUri: false});
    }
  }

you're right, componentDidUpdate expect prevprops and not next ones, I'm planning to take a look at older PR to use functional component instead of the current class component, that will be fixed there

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

No branches or pull requests

2 participants