GithubHelp home page GithubHelp logo

minesweeper's Introduction

minesweeper's People

Contributors

pedroblandim avatar

Watchers

James Cloos avatar Lucas Andrade Oliveira avatar  avatar

minesweeper's Issues

Some refactor

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.

"@types/jest": "^24.0.0",


:React.FCis not needed, TS and infer some types, react component type is one of them

const App:React.FC = () => {


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.

function createEmptyMatrix<T>(rows: number, columns: number, defaultValue: T): T[][]{


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.

const openThisAndPlacesAround = (position: Position) => {


It's important to know the difference between types and interfaces on TS, most of your interfaces should actually by declared as types.

interface ISquare {


When you have a default value on useState you don't need to declare the type, TS can infer.

const [isGameWon, setIsGameWon] = useState<Boolean>(false);


Your project indentation is really strange, I recommend vs-code with the config for 2 spaces (not tabs) for indentation

<EndGameModal isOpen={showGameOverModal}


A nice challenge for the future, try to change localstorage with redux:

const record = window.localStorage.getItem("record");


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;


Also, to understand more read this:
https://blog.timoxley.com/post/47041269194/avoid-else-return-early


I don't think this component should be a class, maybe you can do the same thing using just hooks

class Timer extends React.Component<IProps, {}> {


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.

Recommend Projects

  • React photo React

    A declarative, efficient, and flexible JavaScript library for building user interfaces.

  • Vue.js photo Vue.js

    ๐Ÿ–– Vue.js is a progressive, incrementally-adoptable JavaScript framework for building UI on the web.

  • Typescript photo Typescript

    TypeScript is a superset of JavaScript that compiles to clean JavaScript output.

  • TensorFlow photo TensorFlow

    An Open Source Machine Learning Framework for Everyone

  • Django photo Django

    The Web framework for perfectionists with deadlines.

  • D3 photo D3

    Bring data to life with SVG, Canvas and HTML. ๐Ÿ“Š๐Ÿ“ˆ๐ŸŽ‰

Recommend Topics

  • javascript

    JavaScript (JS) is a lightweight interpreted programming language with first-class functions.

  • web

    Some thing interesting about web. New door for the world.

  • server

    A server is a program made to process requests and deliver data to clients.

  • Machine learning

    Machine learning is a way of modeling and interpreting data that allows a piece of software to respond intelligently.

  • Game

    Some thing interesting about game, make everyone happy.

Recommend Org

  • Facebook photo Facebook

    We are working to build community through open source technology. NB: members must have two-factor auth.

  • Microsoft photo Microsoft

    Open source projects and samples from Microsoft.

  • Google photo Google

    Google โค๏ธ Open Source for everyone.

  • D3 photo D3

    Data-Driven Documents codes.