Skip to content
  • Categories
  • Recent
  • Tags
  • Popular
  • World
  • Users
  • Groups
Skins
  • Light
  • Cerulean
  • Cosmo
  • Flatly
  • Journal
  • Litera
  • Lumen
  • Lux
  • Materia
  • Minty
  • Morph
  • Pulse
  • Sandstone
  • Simplex
  • Sketchy
  • Spacelab
  • United
  • Yeti
  • Zephyr
  • Dark
  • Cyborg
  • Darkly
  • Quartz
  • Slate
  • Solar
  • Superhero
  • Vapor

  • Default (No Skin)
  • No Skin
Collapse
Code Project
Graeme_GrantG

Graeme_Grant

@Graeme_Grant
About
Posts
1.3k
Topics
722
Shares
0
Groups
0
Followers
0
Following
0

Posts

Recent Best Controversial

  • Global Variables rather than context
    Graeme_GrantG Graeme_Grant

    @realJSOP said in Global Variables rather than context:

    I tried to up-vote your answer, but it looks like they've disabled that for now.

    Thanks ... early days...

    React

  • Global Variables rather than context
    Graeme_GrantG Graeme_Grant

    @realJSOP said in Global Variables rather than context:

    well, zustand seems to work pretty well. I'm using the createSelectors paradigm and it's pretty easy to understand and use.

    Glad to hear! I agree, it is far better and more flexible!

    React

  • Global Variables rather than context
    Graeme_GrantG Graeme_Grant

    @realJSOP said in Global Variables rather than context:

    I thought all state changes caused re-renders.

    Zustand does cause UI updates in React, but only for the components that subscribe to the part of the store that changed.

    Here’s how it works:

    • Zustand provides a global store (kind of like Redux, but simpler).
    • When you call useStore((state) => state.someValue), your component subscribes to someValue.
    • If someValue changes (and the equality check shows it’s actually a new value), Zustand triggers a re-render only for that component.
    • Other components that subscribe to different parts of the store won’t re-render unless their slice changes.

    Example:

    import create from "zustand";
    
    const useStore = create((set) => ({
      count: 0,
      increment: () => set((state) => ({ count: state.count + 1 })),
    }));
    
    function Counter() {
      const count = useStore((state) => state.count);
      const increment = useStore((state) => state.increment);
    
      return (
        <button onClick={increment}>
          Count: {count}
        </button>
      );
    }
    
    • Clicking the button calls increment(), which updates count in the store.
    • Zustand detects the change and re-renders only the Counter component (since it subscribed to state.count).

    So... Zustand doesn’t trigger a global re-render like a context provider might. It’s selective and efficient.

    React

  • How to use FastReport .frx file in .NET WinUI3 App?
    Graeme_GrantG Graeme_Grant

    @User-10147035 said in How to use FastReport .frx file in .NET WinUI3 App?:

    ms.Position = 0;
    Before resetting the position, have you set a breakpoint to check that the stream has data? ie: Position > 0?

    Windows Development

  • Is this the correct category for Blazor Server questions
    Graeme_GrantG Graeme_Grant

    @sneha2004sahani2004 said in Is this the correct category for Blazor Server questions:

    Most forums lump Blazor Server and Blazor WASM together

    Hmmm, there are more than two... Blazor Server Static, Blazor Server Interactive, Blazor WebAssembly/WASM, Blazor Auto (Server + WASM), Blazor Hybrid (WinForm, WPF, Analonia, MAUI) ... Then there is StreamRendering...

    .NET (Core and Framework)

  • AI Coding Is Not a "Good Thing (tm)".
    Graeme_GrantG Graeme_Grant

    @realJSOP said in AI Coding Is Not a "Good Thing (tm)".:

    I'm talking about the act of using AI to write code and its implications on the general skill level of people that think AI code generators are reasonable and suitable.

    The sample code given is for a chat with AI, not AI writing code.

    The Soapbox

  • Global Variables rather than context
    Graeme_GrantG Graeme_Grant

    @realJSOP said in Global Variables rather than context:

    Since contexts (and Zustand) just appear to be wrappers around state variables (which cause re-renders when changed)

    Zustand sits outside of the state, so it doesn't directly cause rerenders.

    React

  • AI Coding Is Not a "Good Thing (tm)".
    Graeme_GrantG Graeme_Grant

    @realJSOP said in AI Coding Is Not a "Good Thing (tm)".:

    What say you?

    It's like any tool, garbage in = garbage out.

    The Soapbox

  • Zustand State Manager - real-world examples
    Graeme_GrantG Graeme_Grant

    @realJSOP said in Zustand State Manager - real-world examples:

    I'm old - I don't use AI to write code.

    You miss the point that I was making. It's not about the AI, it's a real-life example of how it can be used.

    React

  • I signed up for Anthropic's Claude model - might go with Kagi's Claude next. Some observations
    Graeme_GrantG Graeme_Grant

    @pkfox said in I signed up for Anthropic's Claude model - might go with Kagi's Claude next. Some observations:

    Hi HTCW, I recently used ChatGP to help me to convert/rewrite an MVC site to Blazor Server and I must say it was very helpful but as you say you have to watch what it gives you carefully - if you tell it exactly what you don't want it actually will improve its offerings - nice to see old names appearing here

    I've spent several weeks experimenting with AI vibe coding and have learned that it is good a small tasks but can't keep focus on larger tasks. You can constrain it through tracking and guidance documents (microsoft vs & vs code call them copilot-instructions.txt). The current issue is 2 fold:

    1. Constraints and guidance turn into hundreds of lines of input.
    2. How much each AI agent can remember before forgetting. A lot gets lost when they summarise.
      So, the further into the prompt they go, the less they remember, the more they improvise, and you lose a lot of control.

    So here is an example with Claude Sonnet 4, the best of the AI models at the moment: I have a library that I wrote recently called Blazing.Mediator. I used the docs as a guide that I gave to the AI. Everything starts well. However, if I let it run for a while and there is one or more summarisations, Claude switches to coding MediatR patterns. Overly opinionated! Then there is the cost...

    I find that I spend a lot of time cleaning up after the AI and lose any gains made if I let it loose on my code, adding new features.

    I now keep it to simple or repetitive tasks - wire-framing, prototyping, initial UI, comments, converting code, fixing errors/warnings, rubber ducking, etc... There are some things that it can do quicker than you without giving you work.

    AI Assisted Coding mcp question visual-studio testing help

  • Is there a Keep Me Logged in type of feature?
    Graeme_GrantG Graeme_Grant

    Yeah, I noticed the same ... Remember Me is missing.

    Site Bugs / Suggestions

  • Is this the correct category for Blazor Server questions
    Graeme_GrantG Graeme_Grant

    @pkfox Blazor is ASP.NET, like WebForms, MVC, Razor Pages, etc... So I would ask your question in ASP.NET forum.

    .NET (Core and Framework)

  • Zustand State Manager - real-world examples
    Graeme_GrantG Graeme_Grant

    @realJSOP said in Zustand State Manager - real-world examples:

    I've watched a couple of videos, but they are very simple examples whose most complicated sample is incrementing/decrementing a counter. Dose anyone have a real-world use case taht can comment on it's functionality?

    Sure. How about the openai-responses-starter-app from OpenAI? Here is one example: useConversationStore.ts

    React

  • Not a fan
    Graeme_GrantG Graeme_Grant

    @realJSOP said in Not a fan:

    I'm currently working on a React (v19) project, and my desktop programmer brain is fighting it. We make extensive use of tables (material-table/core) and custom inputs and I'm currently working at home on a version that makes substantially less use of useStates because they clobber rendering performance. I've managed to duplicate about 90% of our infrastructure and reduced the # of useStates from over 550 to just 47 instances.

    I'm like you with React. Have you looked at Zustand. I only use useState if I have to.

    The Lounge

  • Begun Backing Up My CP Articles
    Graeme_GrantG Graeme_Grant

    raddevus wrote:

    I've begun the (painful) work to save all of my CP articles to my local drive.

    All of my articles are written in Markdown, except for a few early ones, all written locally before uploading. I've done this as I've had a bad experience years ago with PlanetSourceCode....

    Graeme


    "I fear not the man who has practiced ten thousand kicks one time, but I fear the man that has practiced one kick ten thousand times!" - Bruce Lee

    The Lounge html question

  • If CodeProject Never Existed, Where Would You Have Gone?
    Graeme_GrantG Graeme_Grant

    Mike Hankey wrote:

    I've been with CP for over 20 years

    Same...

    Graeme


    "I fear not the man who has practiced ten thousand kicks one time, but I fear the man that has practiced one kick ten thousand times!" - Bruce Lee

    The Lounge com question

  • Where can we all meet up when CP disappears
    Graeme_GrantG Graeme_Grant

    Marc Clifton wrote:

    Though I agree, it would be nice to hear from the new leadership as to the future of CP.

    100% agree ...

    Graeme


    "I fear not the man who has practiced ten thousand kicks one time, but I fear the man that has practiced one kick ten thousand times!" - Bruce Lee

    The Lounge workspace

  • Still alive spammers
    Graeme_GrantG Graeme_Grant

    Is there any point if the lights are on and nobody is home running the show?

    Graeme


    "I fear not the man who has practiced ten thousand kicks one time, but I fear the man that has practiced one kick ten thousand times!" - Bruce Lee

    Spam and Abuse Watch com question lounge

  • No ads
    Graeme_GrantG Graeme_Grant

    Yes ... it's the lights slowly turning off...

    Graeme


    "I fear not the man who has practiced ten thousand kicks one time, but I fear the man that has practiced one kick ten thousand times!" - Bruce Lee

    The Lounge csharp asp-net com debugging tutorial

  • Is anyone running / managing CP at the moment?
    Graeme_GrantG Graeme_Grant

    Work and family have kept me busy, but I try to find time to visit and volunteer as a long-time member. Last night, in the early hours, my wife's sister passed away. Only tonight I logged in and saw the news. It's like last night all over again. This is not the first coding site that I have seen this happen to and it won't be the last. I hope the service lives on under new management or is spun off into a new community site. I will miss everyone.

    Graeme


    "I fear not the man who has practiced ten thousand kicks one time, but I fear the man that has practiced one kick ten thousand times!" - Bruce Lee

    Site Bugs / Suggestions question com sysadmin lounge
  • Login

  • Don't have an account? Register

  • Login or register to search.
  • First post
    Last post
0
  • Categories
  • Recent
  • Tags
  • Popular
  • World
  • Users
  • Groups