Join Alex Banks for an in-depth discussion in this video Asking a question, part of Building a Polling App with Socket IO and React.js.
- Now that we have the questions loaded,…we need to allow the speaker to ask a question.…When a speaker asks the question,…we will update the state of currentQuestion on the server,…and then we will broadcast that question…to every connected socket.…So let's start with the Questions component.…In the Questions component, we are going to go ahead…and add a function for asking a question.…So above the addQuestion here on line four,…I'm going to hit enter a couple of times…and then I will add a function that will allow us…to ask a question.…
And this ask(question) function…should take in the question.…So we will go ahead and inject the question…that the speaker has clicked on there.…And then we can use this.props.emit…to emit an ask event…and send this question to the server.…So now we need to invoke this ask function…when the speaker clicks on the span.…So down here on line 12, I'm going to add onClick handler…to the span.…And when we click the span, we want to call this.ask…but we need to send it some data.…
So the way we do that in React handlers…
- Setting up the environment
- Connecting sockets
- Handling disconnects
- Setting up the React.js router
- Passing state to child components as properties
- Joining the presentation
- Starting and running the presentation
- Asking and answering questions
- Graphing results
- Upgrading to ES6
Skill Level Intermediate
Building a Responsive Single-Page Design with Sasswith Ray Villalobos4h 55m Intermediate
1. Setting Up the Environment
Setting up npm scripts4m 22s
2. Connecting Sockets
3. App State and Routes
4. Joining the Presentation
5. Starting the Presentation
6. Questions and Answers
7. Graphing Results on a Scoreboard
8. Upgrading to ES6 Syntax
Next steps1m 1s
- Mark as unwatched
- Mark all as unwatched
Are you sure you want to mark all the videos in this course as unwatched?
This will not affect your course history, your reports, or your certificates of completion for this course.Cancel
Take notes with your new membership!
Type in the entry box, then click Enter to save your note.
1:30Press on any video thumbnail to jump immediately to the timecode shown.
Notes are saved with you account but can also be exported as plain text, MS Word, PDF, Google Doc, or Evernote.