Git Product home page Git Product logo

Comments (4)

FrancescoCioria avatar FrancescoCioria commented on September 26, 2024

Hi @estill01 ,

Why are you changing the value of TextareAutosize directly?

TextareaAutosize updates its height at every render in the componentDidUpdate, this way you're changing its value outside of the React's lifecycle, therefore componentDidUpdate is never called and the height is never updated.

Is there a reason you're not doing the following?

<TextareAutosize value={this.state.value} onChange={(e) => this.setState({ value: e.target.value }) />
<button onClick={clearTextarea}>Clear</button>

...

function clearTextarea() {
  this.setState({ value: '' })
}

from react-autosize-textarea.

FrancescoCioria avatar FrancescoCioria commented on September 26, 2024

I'm closing this, feel free to open a new issue if you think it's still relevant.

from react-autosize-textarea.

bmamouri avatar bmamouri commented on September 26, 2024

I've got the same issue. In my case the TextArea is not controlled, due to performance reasons. When I update the value property of the TextArea, it doesn't fit to accomodate the text. Is there a way to dispatch the resize event manually?

from react-autosize-textarea.

FrancescoCioria avatar FrancescoCioria commented on September 26, 2024

Disclaimer: I haven't been working on this for a while

There isn't any official API to do that, but I think you could manually import autosize (try installing the same version) and then call autosize.update(textareaRef) where textareaRef is the the value you get from props.innerRef.

This is the call that's happening in componentDidUpdate: https://github.com/buildo/react-autosize-textarea/blob/master/src/TextareaAutosize.tsx#L159

from react-autosize-textarea.

Related Issues (20)

Recommend Projects

  • React photo React

    A declarative, efficient, and flexible JavaScript library for building user interfaces.

  • Vue.js photo Vue.js

    🖖 Vue.js is a progressive, incrementally-adoptable JavaScript framework for building UI on the web.

  • Typescript photo Typescript

    TypeScript is a superset of JavaScript that compiles to clean JavaScript output.

  • TensorFlow photo TensorFlow

    An Open Source Machine Learning Framework for Everyone

  • Django photo Django

    The Web framework for perfectionists with deadlines.

  • D3 photo D3

    Bring data to life with SVG, Canvas and HTML. 📊📈🎉

Recommend Topics

  • javascript

    JavaScript (JS) is a lightweight interpreted programming language with first-class functions.

  • web

    Some thing interesting about web. New door for the world.

  • server

    A server is a program made to process requests and deliver data to clients.

  • Machine learning

    Machine learning is a way of modeling and interpreting data that allows a piece of software to respond intelligently.

  • Game

    Some thing interesting about game, make everyone happy.

Recommend Org

  • Facebook photo Facebook

    We are working to build community through open source technology. NB: members must have two-factor auth.

  • Microsoft photo Microsoft

    Open source projects and samples from Microsoft.

  • Google photo Google

    Google ❤️ Open Source for everyone.

  • D3 photo D3

    Data-Driven Documents codes.