pedroblandim / minesweeper Goto Github PK
View Code? Open in Web Editor NEWA simple Minesweeper game made with React.
A simple Minesweeper game made with React.
All those comments below are valid for all your files.
test and @types dependencies should be installed as devDependencies, you should know the difference between them.
Line 9 in 37eaf42
:React.FC
is not needed, TS and infer some types, react component type is one of them
Line 5 in 37eaf42
There are many better ways to place this function, you can have a file /src/utils.js, or if you're using only here in this components you can put before the component declaration, it's always better to declare stuff before you use them. Take a look at airbnb style guide to learn more about some best practices.
Minesweeper/src/components/Board/index.tsx
Line 359 in 37eaf42
Some places of your file have indentation with 4 spaces, other places have 2 spaces, you must follow a pattern, 2 spaces is the best option in my opinion, airbnb use 2 spaces as well.
Minesweeper/src/components/Board/index.tsx
Line 168 in 37eaf42
It's important to know the difference between types
and interfaces
on TS, most of your interfaces should actually by declared as types.
When you have a default value on useState
you don't need to declare the type, TS can infer.
Your project indentation is really strange, I recommend vs-code with the config for 2 spaces (not tabs) for indentation
A nice challenge for the future, try to change localstorage with redux:
A tip for any language, try to avoid else, to understand an else the dev must always read all ifs and else ifs, so the else can become unclear really easy, prefer:
if (condition 1) .... return;
if (condition 2) .... return;
if (condition 3) .... return;
I don't think this component should be a class, maybe you can do the same thing using just hooks
A challenge for the future: try to replace your css files with styled-components in my opinion it's the better way to add css styles on React components.
A challenge for the future: try to add eslint + prettier config on vs-code, you'll have a much better auto-formatting for your code, and you can also apply of other projects in the future.
A declarative, efficient, and flexible JavaScript library for building user interfaces.
๐ Vue.js is a progressive, incrementally-adoptable JavaScript framework for building UI on the web.
TypeScript is a superset of JavaScript that compiles to clean JavaScript output.
An Open Source Machine Learning Framework for Everyone
The Web framework for perfectionists with deadlines.
A PHP framework for web artisans
Bring data to life with SVG, Canvas and HTML. ๐๐๐
JavaScript (JS) is a lightweight interpreted programming language with first-class functions.
Some thing interesting about web. New door for the world.
A server is a program made to process requests and deliver data to clients.
Machine learning is a way of modeling and interpreting data that allows a piece of software to respond intelligently.
Some thing interesting about visualization, use data art
Some thing interesting about game, make everyone happy.
We are working to build community through open source technology. NB: members must have two-factor auth.
Open source projects and samples from Microsoft.
Google โค๏ธ Open Source for everyone.
Alibaba Open Source for everyone
Data-Driven Documents codes.
China tencent open source team.