packtpublishing / asp.net-core-5-and-react-second-edition Goto Github PK
View Code? Open in Web Editor NEWASP.NET Core 5 and React - Second Edition, published by Packt
License: MIT License
ASP.NET Core 5 and React - Second Edition, published by Packt
License: MIT License
Unhandled Rejection (Error): Objects are not valid as a React child (found: object with keys {map, forEach, count, toArray, only}). If you meant to render a collection of children, use an array instead.
โถ 17 stack frames were collapsed.
initAuth0
E:/core_project/E_projects/dot5/react/QandA/frontend/src/Auth.tsx:50
47 | const user = await auth0FromHook.getUser();
48 | setUser(user);
49 | }
50 | setIsAuthenticated(isAuthenticatedFromHook);
| ^ 51 | setLoading(false);
52 | };
53 | initAuth0();
Hi, i developed my own project throughout the book, and now i have the problem that i don't know how to merge the code that do not use Redux with my project that does. In chapter 12, in "Aborting data fetching", can you show how to solve that using Redux? Thanks in advance!
in step 2 when use combineReducer function i have got an error and i don't know what's wrong please help this error message
No overload matches this call.
Overload 1 of 3, '(reducers: ReducersMapObject<Appstate, any>): Reducer<CombinedState, AnyAction>', gave the following error.
Type '(state: QuestionState | undefined, action: QuestionActions) => QuestionState | { unanswered: QuestionData[]; loading: boolean; unawnsered: QuestionData[]; viewing: QuestionData | null; searched: QuestionData[]; } | { ...; }' is not assignable to type 'Reducer<QuestionState, any>'.
Type 'QuestionState | { unanswered: QuestionData[]; loading: boolean; unawnsered: QuestionData[]; viewing: QuestionData | null; searched: QuestionData[]; } | { ...; }' is not assignable to type 'QuestionState'.
Type '{ viewing: QuestionData | undefined; loading: boolean; unawnsered: QuestionData[]; searched: QuestionData[]; }' is not assignable to type 'QuestionState'.
Types of property 'viewing' are incompatible.
Type 'QuestionData | undefined' is not assignable to type 'QuestionData | null'.
Type 'undefined' is not assignable to type 'QuestionData | null'.
Overload 2 of 3, '(reducers: ReducersMapObject<Appstate, AnyAction>): Reducer<CombinedState, AnyAction>', gave the following error.
Type '(state: QuestionState | undefined, action: QuestionActions) => QuestionState | { unanswered: QuestionData[]; loading: boolean; unawnsered: QuestionData[]; viewing: QuestionData | null; searched: QuestionData[]; } | { ...; }' is not assignable to type 'Reducer<QuestionState, AnyAction>'.
Type 'QuestionState | { unanswered: QuestionData[]; loading: boolean; unawnsered: QuestionData[]; viewing: QuestionData | null; searched: QuestionData[]; } | { ...; }' is not assignable to type 'QuestionState'.
Type '{ viewing: QuestionData | undefined; loading: boolean; unawnsered: QuestionData[]; searched: QuestionData[]; }' is not assignable to type 'QuestionState'. TS2769
I
The book describes using a "user.svg" file in chapter 3 and links to the file here on page 117(kindle): link The file does not exist here. It does however exists in the finish folder instead.
npm install completes OK
npm start leads to following message:
0 info it worked if it ends with ok
1 verbose cli [
1 verbose cli 'C:\Program Files\nodejs\node.exe',
1 verbose cli 'C:\Program Files\nodejs\node_modules\npm\bin\npm-cli.js',
1 verbose cli 'start'
1 verbose cli ]
2 info using [email protected]
3 info using [email protected]
4 verbose run-script [ 'prestart', 'start', 'poststart' ]
5 info lifecycle [email protected]prestart: [email protected]start: [email protected]
6 info lifecycle [email protected]
7 verbose lifecycle [email protected]start: unsafe-perm in lifecycle truestart: PATH: C:\Program Files\nodejs\node_modules\npm\node_modules\npm-lifecycle\node-gyp-bin;C:\Users\Hal\Documents\Packt\ASP.NET-Core-5-and-React-Second-Edition-master fm GitHub\ASP.NET-Core-5-and-React-Second-Edition-master\chapter-03\finish\frontend\node_modules.bin;C:\Program Files (x86)\Common Files\Oracle\Java\javapath;C:\Python38\Scripts;C:\Python38;C:\WINDOWS\system32;C:\WINDOWS;C:\WINDOWS\System32\Wbem;C:\WINDOWS\System32\WindowsPowerShell\v1.0;C:\WINDOWS\System32\OpenSSH;C:\Program Files\dotnet;C:\Program Files\Microsoft SQL Server\130\Tools\Binn;C:\Program Files\Microsoft SQL Server\Client SDK\ODBC\170\Tools\Binn;C:\Program Files (x86)\Windows Kits\10\Windows Performance Toolkit;C:\Program Files (x86)\Microsoft SQL Server\150\DTS\Binn;C:\Program Files (x86)\Microsoft SQL Server\150\Tools\Binn;C:\Program Files\Microsoft SQL Server\150\Tools\Binn;C:\Program Files\Microsoft SQL Server\150\DTS\Binn;C:\Program Files (x86)\Brackets\command;C:\Program Files\nodejs;C:\ProgramData\chocolatey\bin;;C:\Program Files\Azure Data Studio\bin;C:\Program Files (x86)\dotnet;C:\Users\Hal\AppData\Local\Microsoft\WindowsApps;C:\Users\Hal.dotnet\tools;C:\Users\Hal\AppData\Local\Programs\Azure Data Studio\bin;C:\Users\Hal\AppData\Local\Programs\Microsoft VS Code\bin;C:\Users\Hal\AppData\Roaming\npm;C:\Program Files (x86)\DTN\IQFeed;C:\Users\Hal\AppData\Local\Microsoft\WindowsApps;C:\Program Files\Azure Data Studio\bin;C:\Users\Hal.dotnet\tools
8 verbose lifecycle [email protected]
9 verbose lifecycle [email protected]start: CWD: C:\Users\Hal\Documents\Packt\ASP.NET-Core-5-and-React-Second-Edition-master fm GitHub\ASP.NET-Core-5-and-React-Second-Edition-master\chapter-03\finish\frontendstart: Args: [ '/d /s /c', 'react-scripts start' ]
10 silly lifecycle [email protected]
11 silly lifecycle [email protected]start: Returned: code: 1 signal: nullstart: Failed to exec start script
12 info lifecycle [email protected]
13 verbose stack Error: [email protected] start:react-scripts start
13 verbose stack Exit status 1
13 verbose stack at EventEmitter. (C:\Program Files\nodejs\node_modules\npm\node_modules\npm-lifecycle\index.js:332:16)
13 verbose stack at EventEmitter.emit (events.js:315:20)
13 verbose stack at ChildProcess. (C:\Program Files\nodejs\node_modules\npm\node_modules\npm-lifecycle\lib\spawn.js:55:14)
13 verbose stack at ChildProcess.emit (events.js:315:20)
13 verbose stack at maybeClose (internal/child_process.js:1021:16)
13 verbose stack at Process.ChildProcess._handle.onexit (internal/child_process.js:286:5)
14 verbose pkgid [email protected]
15 verbose cwd C:\Users\Hal\Documents\Packt\ASP.NET-Core-5-and-React-Second-Edition-master fm GitHub\ASP.NET-Core-5-and-React-Second-Edition-master\chapter-03\finish\frontend
16 verbose Windows_NT 10.0.19042
17 verbose argv "C:\Program Files\nodejs\node.exe" "C:\Program Files\nodejs\node_modules\npm\bin\npm-cli.js" "start"
18 verbose node v12.17.0
19 verbose npm v6.14.4
20 error code ELIFECYCLE
21 error errno 1
22 error [email protected] start:react-scripts start
22 error Exit status 1
23 error Failed at the [email protected] start script.
23 error This is probably not a problem with npm. There is likely additional logging output above.
24 verbose exit [ 1, true ]
from terminal:
PS C:\Users\Hal\Documents\Packt\ASP.NET-Core-5-and-React-Second-Edition-master fm GitHub\ASP.NET-Core-5-and-React-Second-Edition-master\chapter-03\finish\frontend> npm start
[email protected] start C:\Users\Hal\Documents\Packt\ASP.NET-Core-5-and-React-Second-Edition-master fm GitHub\ASP.NET-Core-5-and-React-Second-Edition-master\chapter-03\finish\frontend
react-scripts start
'react-scripts' is not recognized as an internal or external command,
operable program or batch file.
npm ERR! code ELIFECYCLE
npm ERR! errno 1
npm ERR! [email protected] start: react-scripts start
npm ERR! Exit status 1
npm ERR!
npm ERR! Failed at the [email protected] start script.
npm ERR! This is probably not a problem with npm. There is likely additional logging output above.
lines from package.json:
"scripts": {
"start": "react-scripts start",
"build": "react-scripts build",
"test": "react-scripts test",
"eject": "react-scripts eject"
},
lines from package-lock.json
"react-scripts": {
"version": "4.0.1",
"resolved": "https://registry.npmjs.org/react-scripts/-/react-scripts-4.0.1.tgz",
"integrity": "sha512-NnniMSC/wjwhcJAyPJCWtxx6CWONqgvGgV9+QXj1bwoW/JI++YF1eEf3Upf/mQ9KmP57IBdjzWs1XvnPq7qMTQ==",
"requires": {
...
System.InvalidOperationException: IDX20803: Unable to obtain configuration from: 'System.String'.
---> System.IO.IOException: IDX20807: Unable to retrieve document from: 'System.String'. HttpResponseMessage: 'System.Net.Http.HttpResponseMessage', HttpResponseMessage.Content: 'System.String'.
at Microsoft.IdentityModel.Protocols.HttpDocumentRetriever.GetDocumentAsync(String address, CancellationToken cancel)
at Microsoft.IdentityModel.Protocols.OpenIdConnect.OpenIdConnectConfigurationRetriever.GetAsync(String address, IDocumentRetriever retriever, CancellationToken cancel)
at Microsoft.IdentityModel.Protocols.ConfigurationManager1.GetConfigurationAsync(CancellationToken cancel) --- End of inner exception stack trace --- at Microsoft.IdentityModel.Protocols.ConfigurationManager
1.GetConfigurationAsync(CancellationToken cancel)
at Microsoft.AspNetCore.Authentication.JwtBearer.JwtBearerHandler.HandleAuthenticateAsync()
at Microsoft.AspNetCore.Authentication.JwtBearer.JwtBearerHandler.HandleAuthenticateAsync()
at Microsoft.AspNetCore.Authentication.AuthenticationHandler`1.AuthenticateAsync()
at Microsoft.AspNetCore.Authentication.AuthenticationService.AuthenticateAsync(HttpContext context, String scheme)
at Microsoft.AspNetCore.Authentication.AuthenticationMiddleware.Invoke(HttpContext context)
at Swashbuckle.AspNetCore.SwaggerUI.SwaggerUIMiddleware.Invoke(HttpContext httpContext)
at Swashbuckle.AspNetCore.Swagger.SwaggerMiddleware.Invoke(HttpContext httpContext, ISwaggerProvider swaggerProvider)
at Microsoft.AspNetCore.Diagnostics.DeveloperExceptionPageMiddleware.Invoke(HttpContext context)
ASP.NET-Core-5-and-React-Second-Edition/chapter-12/start/frontend/src/
Store.ts file, which is related to state management using Redux, is introduced in Chapter 7. However, in Chapter 12, this file disappears? What is the reason behind this?
Multiple places ref={register} with following errors: Header.tsx. AskPage.tsx, etc.
Type 'UseFormRegister' is not assignable to type 'LegacyRef | undefined'.
Type 'UseFormRegister' is not assignable to type '(instance: HTMLInputElement | null) => void'.
Types of parameters 'name' and 'instance' are incompatible.
Type 'HTMLInputElement | null' is not assignable to type '"title" | "content"'.
Type 'null' is not assignable to type '"title" | "content"'.
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.