Andarist / react-textarea-autosize

<textarea /> component for React which grows with content
http://andarist.github.io/react-textarea-autosize/
MIT License
2.18k stars 244 forks source link

Simplest example does not work #392

Open d8corp opened 6 months ago

d8corp commented 6 months ago

I create the simplest example with latest versions of libs and chrome. It does not change the textarea height.

Check it here: https://stackblitz.com/edit/stackblitz-starters-3yw9em?file=src%2Findex.tsx

import { createRoot } from 'react-dom/client';
import TextareaAutosize from 'react-textarea-autosize';

const root = createRoot(document.getElementById('app'));

root.render(
  <div>
    <TextareaAutosize />
  </div>
);
Andarist commented 6 months ago

Stackblitz doesnt configure the browser condition here and it picked up a bundle that is meant to be loaded in server environments.

d8corp commented 6 months ago

I updated react-textarea-autosize in my project from 6.1.0 to 8.5.3 to have ref prop and it had broken. the 6.1.0 works on Stackblitz (https://stackblitz.com/edit/stackblitz-starters-enhi95?file=src%2Findex.tsx)

Andarist commented 6 months ago

What bundler do you use in your project?

d8corp commented 6 months ago

webpack, babel-loader 7.1.2 works fine

Andarist commented 6 months ago

What version of webpack? is it a custom configuration or are you using it through some framework~?

d8corp commented 6 months ago

Custom configuration, webpack 4.

VanCoding commented 2 months ago

@Andarist I have the same problem. Changing the "browser" property of package.json from

"browser": {
    "./dist/react-textarea-autosize.esm.js": "./dist/react-textarea-autosize.browser.esm.js"
  },

to

"browser": {
    "./dist/react-textarea-autosize.esm.js": "./dist/react-textarea-autosize.browser.esm.js",
    "./dist/react-textarea-autosize.cjs.js":"./dist/react-textarea-autosize.browser.cjs.js"
  },

seems to solve the problem. I'm still using browserify, though. Is there a reason not to include the cjs version in the "browser" object?