React Native Tutorial #13 - Dismissing the Keyboard
Key Takeaways
Dismisses the keyboard in React Native using TouchableWithoutFeedback
Full Transcript
okay then gang so there's one more little thing I want to do to this out before we move on and talk about flexbox and that is this if currently I start to type something over here a lot of the time when you're on your phone if you click away from the keyboard then it should close the keyboard and the minute I have to press this but not every device has that I suppose and I would like to be able to just click over here like if I click in here again click over here or up here or here and the keyboard is dismissed so it goes away so how do I do that well there's a simple way we can do this so I'm in up J S at the minute and we're returning this component JSX right this is the surrounding container view of everything right here now what I'm going to do is wrap this thing so the whole kind of application if you like with another component and that component is going to be a touchable component now we've already seen these we've seen a touchable opacity component and we can add an unprecedented that this touchable component is going to be slightly different it's going to be called touchable without feedback so when we press something or when we press whatever is inside this touchable component then it won't start to affect the opacity of what's inside it that's what without feedback means so first of all we need to import that and I can do that up here switchable without feedback now we need to import one more thing as well and that is going to be the keyboard because ultimately we're going to be using this keyboard object right here to dismiss the keyboard so first of all we want to surround our entire component with that touchable without feedback component so up here I'm gonna say touchable without feedback like so and take the closing tag and paste it all right at the bottom like that and scoot this in a little bit now we can add on and on press handler right here and this is going to be an anonymous front like so so what I'm gonna do first of all is console dot log and then we'll just say dismissed keyboard now we've not dismissed it at the minute I'm just logging this to show you whenever we click on anything now in this screen because this touchable without feedback component surrounds everything so we can touch anywhere on this screen now then it's going to fire this function and then this should be logged to the console so let me save that and now if I click here then we should see if I go to this thing over here dismissed keyboard let me try somewhere else up here in the header and you can probably hear that little click as I do that dismissed keyboard so now we can listen to touch events everywhere right and what we want to do at this moment in time is actually dismiss the keyboard so if I open this up if I touch over here I want it to move that thing down the keyboard now that's why we imported this keyboard thing at the top right here we can use this now to dismiss the keyboard by saying down here keyboard where the caps okay dots dismiss so this method dismisses the keyboard so now if I start to type something but then click away and it dismisses the keyboard it brings it back down let's try that again bring it up click over here dismisses the keyboard awesome so there we go my friends that is pretty much this app done now right so in the next video what I want to do is move on and talk about flexbox and in fact what we'll do is we'll apply what we learn about flexbox to this app so that we can maybe add something else to it in the future but first of all let's learn about the basics of flexbox in the very next tutorial
Original Description
----------------------------------------
🐱💻 🐱💻 Course Links:
Course files - https://github.com/iamshaunjp/react-native-tutorial
🐱💻 🐱💻 Other Related Courses:
+ Complete React Tutorial - https://www.youtube.com/watch?v=OxIDLw0M-m0&list=PL4cUxeGkcC9ij8CfkAY2RAGb-tmkNwQHG
+ React Hooks & Context Tutorial - https://www.youtube.com/watch?v=6RhOzQciVwI&list=PL4cUxeGkcC9hNokByJilPg5g9m2APUePI
+ Modern JavaScript Tutorial - https://www.youtube.com/watch?v=iWOYAxlnaww&list=PL4cUxeGkcC9haFPT7J25Q9GRB_ZkFrQAc
Watch on YouTube ↗
(saves to browser)
Sign in to unlock AI tutor explanation · ⚡30
Playlist
Uploads from Net Ninja · Net Ninja · 0 of 60
← Previous
Next →
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
Regular Expressions (RegEx) Tutorial #14 - Matching a Username
Net Ninja
Regular Expressions (RegEx) Tutorial #15 - Email RegEx Pattern
Net Ninja
Regular Expressions (RegEx) Tutorial #16 - Finishing Touches
Net Ninja
GraphQL Tutorial #1 - Introduction to GraphQL
Net Ninja
GraphQL Tutorial #2 - A Birdseye View of GraphQL
Net Ninja
GraphQL Tutorial #3 - Project (stack) Overview
Net Ninja
GraphQL Tutorial #4 - Making Queries (front-end preview)
Net Ninja
GraphQL Tutorial #5 - Express App Setup
Net Ninja
GraphQL Tutorial #6 - Setting up GraphQL
Net Ninja
GraphQL Tutorial #7 - GraphQL Schema
Net Ninja
GraphQL Tutorial #8 - Root Query
Net Ninja
GraphQL Tutorial #9 - The Resolve Function
Net Ninja
GraphQL Tutorial #10 - Testing Queries in Graphiql
Net Ninja
GraphQL Tutorial #11 - GraphQL ID Type
Net Ninja
GraphQL Tutorial #12 - Author Type
Net Ninja
GraphQL Tutorial #13 - Type Relations
Net Ninja
GraphQL Tutorial #14 - GraphQL Lists
Net Ninja
GraphQL Tutorial #15 - More on Root Queries
Net Ninja
GraphQL Tutorial #16 - Connecting to mLab
Net Ninja
GraphQL Tutorial #17 - Mongoose Models
Net Ninja
GraphQL Tutorial #18 - Mutations
Net Ninja
GraphQL Tutorial #19 - More on Mutations
Net Ninja
GraphQL Tutorial #20 - Updating the Resolve Functions
Net Ninja
GraphQL Tutorial #21 - GraphQL NonNull
Net Ninja
GraphQL Tutorial #22 - Adding a Front-end
Net Ninja
GraphQL Tutorial #23 - Create React App
Net Ninja
GraphQL Tutorial #24 - Book List Component
Net Ninja
GraphQL Tutorial #25 - Apollo Client Setup
Net Ninja
GraphQL Tutorial #26 - Making Queries from React
Net Ninja
GraphQL Tutorial #27 - Rendering Data in a Component
Net Ninja
GraphQL Tutorial #28 - Add Book Component
Net Ninja
GraphQL Tutorial #29 - External Query File
Net Ninja
GraphQL Tutorial #30 - Updating Component State
Net Ninja
GraphQL Tutorial #31 - Composing Queries
Net Ninja
GraphQL Tutorial #32 - query variables
Net Ninja
GraphQL Tutorial #33 - Re-fetching Queries
Net Ninja
GraphQL Tutorial #34 - Book Details Component
Net Ninja
GraphQL Tutorial #36 - Styling the App
Net Ninja
GraphQL Tutorial #35 - Making a Single Query
Net Ninja
Build Apps with Vue & Firebase - Udemy Course
Net Ninja
Updated Vue & Firebase Course (Udemy)
Net Ninja
Vue & Firebase Real-time Chat (Preview) #1 - Intro
Net Ninja
Vue & Firebase Real-time Chat (Preview) #2 - Project Structure
Net Ninja
Vue & Firebase Real-time Chat (Preview) #3 - Firestore Setup
Net Ninja
Vue & Firebase Real-time Chat (Preview) #4 - Welcome Screen
Net Ninja
Vue & Firebase Real-time Chat (Preview) #5 - Props in Routes
Net Ninja
Vue & Firebase Real-time Chat (Preview) #6 - Route Guards
Net Ninja
Vue & Firebase Real-time Chat (Preview) #7 - Chat Window
Net Ninja
Vue & Firebase Real-time Chat (Preview) #8 - New Message Component
Net Ninja
Object Oriented JavaScript Tutorial #1 - Introduction
Net Ninja
Object Oriented JavaScript Tutorial #2 - Object Literals
Net Ninja
Object Oriented JavaScript Tutorial #3 - Updating Properties
Net Ninja
Object Oriented JavaScript Tutorial #4 - Classes
Net Ninja
Object Oriented JavaScript Tutorial #5 - Class Constructors
Net Ninja
Object Oriented JavaScript Tutorial #6 - Class Methods
Net Ninja
Object Oriented JavaScript Tutorial #7 - Method Chaining
Net Ninja
Object Oriented JavaScript Tutorial #8 - Class Inheritance
Net Ninja
Object Oriented JavaScript Tutorial #9 - Constructors (under the hood)
Net Ninja
Object Oriented JavaScript Tutorial #10 - Prototype
Net Ninja
Object Oriented JavaScript Tutorial #11 - Prototype Inheritance
Net Ninja
More on: React
View skill →Related Reads
📰
📰
📰
📰
How I made a scroll-scrubbed video portfolio fast (Next.js 15 + GSAP + canvas)
Dev.to · Pratham Sharma
5 Reasons HTML Is About to Change Frontend Development
Medium · Programming
5 Reasons HTML Is About to Change Frontend Development
Medium · JavaScript
copilot browser tools make the frontend reviewable
Dev.to · Paulo Victor Leite Lima Gomes
🎓
Tutor Explanation
DeepCamp AI