…HTML into its own component.Modern React best practices recommend separating out each component in your app into a separate file. We'll be following this principle so, in your projects /src/components/ folder, create a new file called Header.js and open it in a text editor.At the top of component files we…
…HTML button inside the closing div wrapper in App.js.<div className="add-movies"><button onClick={this.loadAdditionalMovies}>Load more...</button></div>When the button is clicked, a class method loadAdditionalMovies is called. Add this method to the <App /> component class:loadAdditionalMovies() { var currentMovies = { ...this.state.movies }; var newMovies = Object.assign( currentMovies, additionalMovies ); this.setState({ movies: newMovies }); }Updating…
…html#/.Creating the Tag PageLet's start by creating a link for the user to add a tag to the MongoDB database. In the index.html page, add one more li for the Add Tag page.<li role="presentation" id="tagHyperlink"><a href="/home#/addTag">Tag</a></li>When the user clicks the Add Tag link, it should display the AddTag React component.…
…HTMLElement; let mockPaste: Pastebin[]; // beforeEach is called once before every `it` block in a test. // Use this to configure to the component, inject services etc. beforeEach(()=> { TestBed.configureTestingModule({ declarations: [ PastebinComponent ], // declare the test component imports: [ HttpModule], }); fixture = TestBed.createComponent(PastebinComponent); comp = fixture.componentInstance; de…
…HTML).not.toContain("source-modal"); }) it('should display the modal when `create Paste` is clicked', () => { let createPasteButton = fixture.debugElement.query(By.css("button")); //triggerEventHandler simulates a click event on the button object createPasteButton.triggerEventHandler('click',null); fixture.detectChanges(); expect(element.innerHTML).toContain("source-modal"); }) })As previously mentioned, we won't be writing rigorous UI tests. Instead, we will write some basic tests for the…
…* { box-sizing: border-box; } body {margin: 0;}*{box-sizing:border-box;}body{margin-top:0px;margin-right:0px;margin-bottom:0px;margin-left:0px;} React is a popular JavaScript front-end library for building interactive user interfaces. React has a comparatively shallow learning curve, which is one of the reasons why it's getting all the attention lately. Although there are many important concepts to be covered, components…
…What You'll Be CreatingAre you familiar with the term "spaghetti code"? This is a metaphor you might hear from non-JavaScript developers in criticism of the language. It is code with no structure. It will consist of line after line of statements. Some may be wrapped in functions, some not at…
…* { box-sizing: border-box; } body {margin: 0;}*{box-sizing:border-box;}body{margin-top:0px;margin-right:0px;margin-bottom:0px;margin-left:0px;} We have come a long way in learning TypeScript since starting this series. The first tutorial gave you a brief introduction to TypeScript and suggested some IDEs that you can use for writing TypeScript. The second tutorial focused on data types, and…
…html │ ├── main.ts │ ├── polyfills.ts │ ├── styles.css │ ├── test.ts │ ├── tsconfig.app.json │ ├── tsconfig.spec.json │ └── typings.d.ts ├── tsconfig.json └── tslint.json 5 directories, 19 files The default project template created by Protractor depends on two files to run the tests: the spec files that reside…
…html'); }); server.listen(8080, () => { console.log('Server started on port 8080') }) This file imports Express and the Express File Upload libraries, configures the web application to use the File Upload, and listens on port 8080. It also creates a route using Express at "/" which will be the default…