nickovchinnikov / minesweeper Goto Github PK
View Code? Open in Web Editor NEWMinesweeper game step-by-step guide
License: MIT License
Minesweeper game step-by-step guide
License: MIT License
Igal Kleiner comment:
In React 18 the FunctionComponent interface was changed and the implicit 'children' prop was omitted. You can find the reason here. Now you have to include the 'children' type by yourself. So here's the full solution. That will fix the "Property 'children' does not exist on type {}" error:
import { FC, PropsWithChildren } from 'react'
// ...rest of the code
interface HeaderProps {
logo: string
}
interface LinkProps {
href: string
target?: '_blank' | '_self' | '_parent' | '_top'
rel?: string
}
const Header: FC<PropsWithChildren<HeaderProps>> = ({ children, logo }) => (
<header className='App-header'>
<img src={logo} className='App-logo' alt='logo' />
{children}
</header>
)
const Link: FC<PropsWithChildren<LinkProps>> = ({ children, href, target = '_blank', rel = 'noopener noreferrer' }) => {
return (
<a className='App-link' href={href} target={target} rel={rel}>
{children}
</a>
)
}
Notice that 'PropsWithChildren' import. If, for example, you only want to use the 'children' prop, without passing any other prop, then you can use it without stating the props type for PropsWithChildren, ie:
const MyComponent: FC<PropsWithChildren> = ({ children }) => <div>{ children }</div>
Cheers!
Note about Webpack 5
As of Webpack 5, there's no need to install url-loader. Webpack 5 ships with Asset Modules, which replace url-loader, raw-loader and file-loader by adding 4 new module types - asset/resource, asset/inline, asset/source and asset. In my case, I wanted to copy all assets to the assets folder, so this was my configuration:
module.exports = {
output: {
// ...other output configurations
assetModuleFilename: 'assets/[hash][ext][query]',
},
module: {
rules: [
// ...other rules,
{
test: /\.(png|jpg|gif|svg)$/i,
type: 'asset/resource',
},
],
},
}
And, of course, you can test it for .svg only:
test: /\.svg/,
Perhaps someone will find it helpful!
Cheers!
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.