ค้นหาเว็บไซต์
ฉันกำลังใช้ Jest และ Enzyme เพื่อทดสอบโปรเจกต์ React ที่เขียนด้วย TypeScript ฉันมีคอมโพเนนต์หนึ่งที่ถูกห่อหุ้มใน React-Router router และมันหน้าตาประมาณนี้:
import { SomeButton } from './someButton'; import { RouteComponentProps, withRouter } from 'react-router'; const SomeButtonWithRouter = withRouter<{buttonCallback: () => void}>(SomeButton); export class SomePage extends React.Component <RouteComponentProps<{}>, {}> { constructor(props: {}) { super อ่านต่อไป →
สมมติว่าฉันมีคอมโพเนนต์ที่ชื่อ 'MyComponent' และฉันต้องการเก็บมันไว้ในตัวแปรประเภท 'MyComponent' ใน TypeScript แต่ใช้องค์ประกอบ JSX เพื่อเริ่มต้นมัน อะไรประมาณนี้:
let comp: MyComponent = <MyComponent somePropInit={3} />โค้ดข้างต้นสร้างข้อผิดพลาดเช่น:
'property 'componentDidMount' หายไปในชนิด 'Ele
อ่านต่อไป →
ฉันกำลังใช้เทมเพลต ASP.NET 2.0 react SPA เวอร์ชันล่าสุด ซึ่งสร้างขึ้นด้วยคำสั่ง dotnet new react. มันใช้งานได้ดีทันทีโดยไม่ต้องปรับแต่ง ซึ่งรองรับการแทนที่โมดูลแบบร้อน (การแก้ไขโค้ดจะอัปเดตในเบราว์เซอร์โดยอัตโนมัติ)
จากนั้นฉันต้องการเพิ่มคอนเทนเนอร์แอประดับบนสุด ชื่อว่า App เพื่อเก็บสถานะของแอปพล
อ่านต่อไป →ฉันได้รับข้อผิดพลาดดังต่อไปนี้ในคอมโพเนนต์ React ขณะพัฒนาด้วย TypeScript:
Argument of type 'React.ReactInstance' is not assignable to parameter of type 'React.ReactInstance'. Type 'Component<any, {}>' is not assignable to type 'ReactInstance'. Type 'React.Component<any, {}>' is not assignable to type 'React.Component<any, {}>'. Two different types with this name exist, but they are unrelated.นี่คือโค้ด (หวังว่าส่วนที่เกี่
อ่านต่อไป →ฉันติดตั้ง react-router-dom ลงในเว็บไซต์ react-redux ที่ใช้ typescript ของฉันแล้ว ตอนนี้ฉันพบข้อผิดพลาดตามชื่อเรื่องของหัวข้อของฉัน, package.json ของฉัน:
{ "name": "typescript-webpack-react-flux-boilerplate", "version": "1.0.0", "license": "MIT", "repository": { "type": "git", "url": "git+https://github.com/pepaar/typescript-webpack-react-flux-boilerplate.git" }, "scripts": { "start": "node se อ่านต่อไป →ฉันใช้เครื่องมือ create-react-app พร้อมกับสคริปต์ typescript เพื่อสร้างโปรเจกต์ react เริ่มต้นโดยใช้ typescript จากนั้นฉันพยายามเพิ่ม react-uwp โดยใช้ npm (--save) มันติดตั้งได้เรียบร้อยและอยู่ในโฟลเดอร์ node_modules ของฉัน ฉันได้แก้ไขไฟล์ tsconfig.json ของฉันตามที่หน้าการเริ่มต้นใช้งานสำหรับ react-uwp ระบุ (ที่นี่: https://www.react-uwp.com/Get-Started)
มีสองตัวเลือก:
ฉันมีคอมโพเนนต์ที่สืบทอดจากคลาสนามธรรมและใช้ตัวตกแต่งของ mobx แบบนี้:
@inject("matrixStore") @observer export default class DayRow<T extends IAbstractRowProps = IAbstractRowProps> extends AbstractRow<T> { // ... }ฟังก์ชัน render อยู่ในคอมโพเนนต์ AbstractRow เอง
ฉันสืบทอดจาก DayRow พร้อมกับคอมโพเนนต์อื่น:
@inject("matrixStore") @observer export default class DayFinderRow extends DayRow<IDayFinderRowProps> { } อ่านต่อไป →มีตัวอย่างมากมายออนไลน์ที่ใช้ไวยากรณ์ของ Babel ฉันได้ลองใช้แล้ว แต่ส่วนใหญ่ไม่สามารถใช้งานร่วมกับ Typescript 2.1 ได้
อ่านต่อไป →
ฉันกำลังพยายามหาวิธีเขียนคำจำกัดความประเภทสำหรับ react-highlight (คลาส Highlightable ดูที่นี่) เพื่อ ขยาย Highlightable และเพิ่มฟังก์ชันการทำงานที่กำหนดเอง เนื่องจากคลาส JS ดั้งเดิมของ Highlightable เป็นซับคลาสของ React.Component ฉ
อ่านต่อไป →ฉันมีคอมโพเนนต์ dropdown ของ primeng....
<form [formGroup]="skillsForm"> <p-dropdown [options]="experienceList" optionLabel="name" formControlName="example" ></p-dropdown> </form>ลึกลงไปภายในกลุ่มฟอร์มที่ซ้อนกันและอาร์เรย์ ดังนั้นฉันต้องใช้ฟอร์มเชิงปฏิกิริยา
ฉันพยายามที่จะรับค่าของตัวเลือกโดยใช้
skillsForm.value.exampleและรับสิ่งของนั้น
{name: 'Over a year', value: '1.0'} อ่านต่อไป →