r/learnjavascript • • Jan 09 '21

I created a simple chat app with React, TailwindCSS, Node, and Socket.io! Started using the basic overview available on socket.io. IMHO, easy to use and understand. :)

Post image
216 Upvotes

26 comments sorted by

6

u/[deleted] Jan 09 '21

Github: https://github.com/lucasmrl/chat-app
Demo: http://chat-app-on.herokuapp.com/

I have some ideas for real-time apps, and this project was meant to give me an idea on how to use Socket.IO. Fun experience! Easy to use!

Glad to answer any questions from the newbies like me. šŸ˜…

7

u/serverNinja25 Jan 09 '21

How is tailwindCSS ? Wanted to try but never got to it. Is it better than pure css? Oh btw I really like the style of the website

4

u/[deleted] Jan 09 '21

I already used it for 2 other projects:
https://github.com/lucasmrl/roomie
http://showdev.live/

As u/serverNinja25 said, I don't think it is "better". It is a different tool on top of CSS.
For me, it was really good to actually better understand CSS.
For this kind of project, IMHO it is just faster to get a nice layout without too much thinking.

I am not sure how many companies use Tailwind, but it is definitely worth it to know if you, like me, prefer to focus on the backend, instead of the frontend. :)

4

u/[deleted] Jan 09 '21

Better than pure CSS? Nope, I don't think so.

Even so, the only reason someone should use any library is for productivity reasons.

Tailwind already provides many built-in CSS Classes

You simply write the html/jsx and you already have a responsive website (if handled correctly)

4

u/Hawkburr Jan 09 '21

I tried the demo but don’t see anything in the chat, using mobile Safari latest iOS.

1

u/[deleted] Jan 09 '21

u/Hawkburr wow, thanks for that. I will get a device to test it today. Are you able to see it on Chrome?

2

u/Luckyfive Jan 09 '21

Doesn’t work in iOS chrome either

1

u/[deleted] Jan 09 '21

What do you see? I think I know what the problem is

2

u/Luckyfive Jan 09 '21

I can type messages out but nothing shows up in the chat. Sometimes I see messages from other users but that’s rare. Most of the time it just says ā€œnull has left the chatā€

1

u/[deleted] Jan 09 '21

Gotcha. I will fix it! Thanks

2

u/shittyphotodude Jan 09 '21

Saving this to work though later. Awesome work man, looks clean!

2

u/[deleted] Jan 09 '21

u/shittyphotodude thanks man!!!

2

u/interactionjackson Jan 09 '21

i saw your big o comment on disconnect. why do you have to search through the map. delete with the id and handle any errors. don’t loop.

1

u/[deleted] Jan 09 '21

u/interactionjackson great! So, I am doing that because the way I store the sockets is by the "nickname" as the key, and each key an an array with 2 "IDS" (socket.client.id AND socket.id). Maybe I am missing something, but I do that, in order to know the "nickname", so I can send it back to the client.

2

u/interactionjackson Jan 11 '21

ah, i see. you would need to store the id as the key for my suggestion to work.

1

u/[deleted] Jan 11 '21

I just fixed some small bugs, but I will take a look at this asap. Thanks u/interactionjackson

2

u/RoguePlanet1 Jan 09 '21

How hard is it to incorporate different libraries? Just plug in, refer to the documentation, and have at it? Like React and JS basically, I'm guessing.

2

u/[deleted] Jan 09 '21

u/RoguePlanet1 Yes, that is the idea! Then, your good old friend Stackoverflow! :) lol

3

u/RoguePlanet1 Jan 09 '21

Stack Overflow is frustrating, doesn't usually help me. But I need to start venturing into documentation and giving that a try! Seems like the people who give tutorials say that's how they learned each type of code on their own.

2

u/[deleted] Jan 09 '21

You are right. Documentation is a great way to solve questions. I think we all tend to go to tutorials because they give us everything ready.

For Socket.io, for example, take a look here: https://socket.io/get-started/chat/

Their "Get started" is basically the simple version of what I built. But they use node, socket.io, and HTML with Js.

The real learning experience comes when you try to change it. Instead of pure html/JS, How can you use React/Vue/etc? At the bottom, they have some feature suggestions to implement but they don't give you the answer. If you at at their documentaion, there are the necessary things to do it at least start on the right path to build that feature.

2

u/RoguePlanet1 Jan 09 '21

Thanks! I have an idea for a simple app, and am not sure how to even begin (even though I've worked with React/JS and followed tutorials.) How do you figure out which languages are best for what you want to accomplish? Or are they mostly equally effective?

Was hoping to incorporate a map in it, so a person can have their location detected automatically (that part might be asking too much) and the map showing them locations (retail or private) that other users have marked temporarily.

2

u/[deleted] Jan 11 '21

u/RoguePlanet1 Sorry for taking so long.

Regarding languages: I am way more comfortable with Javascript than with Java or C#, that I also have a little experience. Since I know this one, I decided to go with this one. By the way, since this is just a small project for learning purposes, I am not too concerned with performance issues like having 1902813 users online.

Regarding your idea, it is an interesting project, go for it!
How much do you know about backend? I would list all the features that you want, and focus on one at a time, for example:

  1. User is able to access my app and we store their location in a database

  2. User is able to add/remove/update/delete a place on our database

  3. Display Map on the screen displaying all places added by the users

  4. User is able to click in a "place" and see more information.

And so on...

I used something similar here:
http://roomiew.herokuapp.com/listings

1

u/RoguePlanet1 Jan 12 '21

Pretty much, a sort of freecycle-type thing, where one user (I'm expecting a retail establishment) can say "this type of thing is available at this location, come and get it soon" and people in the immediate area can swing by.

Once picked up, the post can be deleted somehow/marked as "done," something like that. Kinda like Krispy Kreme has the sign indicating "Hot Donuts" to passers-by.

User could click on the location, see a bit more detail (that maybe the store/person could fill in with a drop-down list.) Not sure how practical of an idea this is though.

2

u/shortpoet Jan 09 '21

Sweet project!! I’m curious what your inspirations were? Just the docs? Did you look at any guides, tutorials, or other repos? Curious about ā€œreferencesā€ to help trace the thought process.

2

u/[deleted] Jan 11 '21

u/shortpoet So, I have a few big ideas for real-time apps. I knew about Socket.io but I never tried. They "get started" is actually a simple version of a chat:
https://socket.io/get-started/chat/

I would argue that almost all tutorials on the internet related to Socket.io are for chats. lol. With even more features than the one that I have. Since I wanted to learn, I used a lot there official documentation to try to figure out how to do what I wanted.

There are a lot of useful resources on Stack overflow too. :)

1

u/shortpoet Jan 12 '21

Gotta love some good docs!! šŸ¤“ Thank you for the response!! I look forward to digging into this some more!