Hi,
Having trouble enabling PNPM in your AWS Amplify Gen 2 project?
Not a problem here is the YAML configuration
Happy coding!
Adventures in Brogramming Born, Raised and Grinding Proudly in Toronto, Ontario, Canada
Hi,
Having trouble enabling PNPM in your AWS Amplify Gen 2 project?
Not a problem here is the YAML configuration
Happy coding!
A shortie but a goodie
Ever want to look at the request body, the request headers and so on in .NET Web API ?
Well, that doesn't exactly tell you how to do it. In fact, nothing does. Microsoft wants you to work at a higher level of abstraction than looking at the request. But we all know that isn't always a good idea or possible. Time to quit back to NodeJS?
If you look at Stack Overflow you will see many answers like this
string result = await Request.Content.ReadAsStringAsync();
The
dispatchEvent()
method of theEventTarget
sends anEvent
to the object, (synchronously) invoking the affected event listeners in the appropriate order. The normal event processing rules (including the capturing and optional bubbling phase) also apply to events dispatched manually withdispatchEvent()
.Calling
dispatchEvent()
is the last step to firing an event. The event should have already been created and initialized using anEvent()
constructor.
Once the component has been initially rendered, you can trigger further renders by updating its state with the set function. Updating your component’s state automatically queues a render. (You can imagine these as a restaurant guest ordering tea, dessert, and all sorts of things after putting in their first order, depending on the state of their thirst or hunger.) React.Dev "Managing State"
If you see too much of your screen rendering making it slow when taking actions (like clicking) break it down
Make more components... obvious, but worth mentioning the obviousUntil next time...
Eventually you will reach a point in your career where you need or want to make dynamic GraphQL queries
You probably are used to static queries strongly typed from a schema.graphql with autocomplete in VSCode
How the hell can that change or be data driven?
Well the answer is in the specificationTypically validation is performed in the context of a request immediately before execution, however a GraphQL service may execute a request without immediately validating it if that exact same request is known to have been validated before. A GraphQL service should only execute requests which at some point were known to be free of any validation errors, and have since not changed.
For example: the request may be validated during development, provided it does not later change, or a service may validate a request once and memoize the result to avoid validating the same request again in the future.
Request may be validated during development => request may be validated during runtime => request may change!
For example with graphql-tag
GraphQL strings are the right way to write queries in your code, because they can be statically analyzed using tools like eslint-plugin-graphql. However, strings are inconvenient to manipulate, if you are trying to do things like add extra fields, merge multiple queries together, or other interesting stuff.
That's where this package comes in - it lets you write your queries with ES2015 template literals and compile them into an AST with the gql tag.
With string interpolation, "dynamic GraphQL" is actually trivial! Just build the string! (And this is JavaScript not Java so you don't need a StringBuilder!)
So,
a) RTFM (in this case the specification!)
b) Never trust the "right way"
c) Look for an existing solution
d) Probably more things I haven't thought of...
Back to basics!
According to react.dev "Rules of Hooks" you cannot call hooks inside a condition
https://react.dev/warnings/invalid-hook-call-warning#breaking-rules-of-hooks
But what if you want it?
export const ParentComponent = ({ component }: ParentComponentProps) => {
/* derive condition here */
// const condition = false;
const condition = true;
/* derive property here */
// cont property = 0;
// ...
return (<>
{
condition && <HookComponent hookProperty={property} />
}
</>);
}
export const HookComponent = ({ hookProperty }: ChildComponentProps) => {
useCustomHook(hookProperty); // could be anything!
return <></>; // yes, components can render nothing
}
With great power comes great responsibility!