-
Notifications
You must be signed in to change notification settings - Fork 492
key on React Component does not compile #300
Comments
i think there is something else you aren't reporting here. it says the
error is on `length`, but you dont use the word `length` in your app.
…On Mon, Apr 9, 2018 at 5:44 AM, GUENEGO Jean-Louis ***@***.*** > wrote:
Is this a bug report?
Yes
Can you also reproduce the problem with npm 4.x?
Yes
Which terms did you search for in User Guide?
key
Module build failed: TypeError: Cannot read property 'length' of undefined
Environment
D:\repos\zzz_react_ts>npm ls react-scripts-ts
***@***.*** D:\repos\zzz_react_ts
`-- ***@***.***
D:\repos\zzz_react_ts>node -v
v9.4.0
D:\repos\zzz_react_ts>npm -v
4.6.1
Then, specify:
1. Operating system: Windows 10
2. Browser and version (if relevant):
Chrome 65
Steps to Reproduce
npm install -g create-react-app
create-react-app zzz --scripts-version=react-scripts-ts
cd zzz
npm start
(Write your steps here:)
1. Replace App.tsx with the following content:
import * as React from 'react';
import './App.css';
const MyComp = () => <div>bar</div>;
class App extends React.Component {
render() {
return (
<div>
{[0, 1, 2].map(n => <MyComp key={n}/>)}
</div>
);
}
}
export default App;
Expected Behavior
You should see no error in the browser, and a loop printed.
Actual Behavior
Error in the browser:
./src/App.tsx
Module build failed: TypeError: Cannot read property 'length' of undefined
The bug is on MyComp key={n}
Reproducible Demo
zzz_react_ts.zip
<https://github.com/wmonk/create-react-app-typescript/files/1889289/zzz_react_ts.zip>
—
You are receiving this because you are subscribed to this thread.
Reply to this email directly, view it on GitHub
<#300>, or mute
the thread
<https://github.com/notifications/unsubscribe-auth/AiT1gs1Rx1_BE9XQ8mk7oGqGdC4HVVdaks5tmy2LgaJpZM4TMPio>
.
|
Does |
It would be good if it was because of this. But unfortunately not ;) |
@tsiq-swyx Unfortunately the compiler seems to be very silent. Please try the example in the zip ;) |
i tried it and i can replicate the error. the problem looks like it is inside webpackhotdev client it is probably something to do with the context also even when you use a string it doesnt work
so either the key or the map is currently broken in this version 2.14.0. im not a maintainer here so i dont have any other info. |
On first build, you will get additional details in the browser console like this:
This seems to be a regression introduced in The same code works fine in 2.7.2. If you feel a bit adventurous, you might as well try |
I agree with this analyze. Temporary fix:
Thanks guys you're genious and made my day ! |
Is this a bug report?
Yes
Can you also reproduce the problem with npm 4.x?
Yes
Which terms did you search for in User Guide?
key
Module build failed: TypeError: Cannot read property 'length' of undefined
Environment
D:\repos\zzz_react_ts>npm ls react-scripts-ts
[email protected] D:\repos\zzz_react_ts
`-- [email protected]
D:\repos\zzz_react_ts>node -v
v9.4.0
D:\repos\zzz_react_ts>npm -v
4.6.1
Then, specify:
Chrome 65
Steps to Reproduce
npm install -g create-react-app
create-react-app zzz --scripts-version=react-scripts-ts
cd zzz
npm start
(Write your steps here:)
Expected Behavior
You should see no error in the browser, and a loop printed.
Actual Behavior
Error in the browser:
./src/App.tsx
Module build failed: TypeError: Cannot read property 'length' of undefined
The bug is on
MyComp key={n}
Reproducible Demo
zzz_react_ts.zip
The text was updated successfully, but these errors were encountered: