• 0 Posts
  • 223 Comments
Joined 2 years ago
cake
Cake day: June 13th, 2023

help-circle




  • briantoReactCount child elements HOC
    link
    fedilink
    arrow-up
    2
    ·
    10 days ago

    yeah there isn’t really a general purpose react way to do that.

    if order didn’t matter then you could just have a Header component that registers itself in a context but there’s no way to know where each component is relative to its siblings.

    the other way is to break out of react and just walk the dom. pass a ref to your component and use that as the root to walk. only works assuming normal react dom renderer and no portals.

    you can combine those two options too, use context for registration so you can attach extra info, then dom for position.

    there are some libs that let you walk a component tree, but they’re all focused on ssr and idk how they work in a browser. wouldn’t go this route for anything prod.

    last option is just store your content as data. have md/mdx/json/whatever files that are the content for your page, then as you parse them build up the tree. probably the most robust if it fits your use case. if you use MDX it seems like they already have some solutions





  • I’d assume most people on minimal split keyboards use vim bindings or similar. that’s what I usually do and I have a quefrency and wireless corne. I only end up using fn keys if I’m playing games. for programming I’d rather have mnemonic chords like <space> p c for project menu then compile instead of remembering f7 or whatever

    on that note though, a quefrency might fit your needs. it has 8 fn keys on the side and the others on a layer. otherwise you can always get custom pcbs, it’s work but it’s not that bad







  • briantoProgrammingWhen Your Last Name Is Null, Nothing Works
    link
    fedilink
    arrow-up
    1
    arrow-down
    1
    ·
    edit-2
    30 days ago

    json is fine as a serialization format for things that need to be text, but it’s not great as something that gets edited by hand.

    not that I enjoy xml, but writing long strings in json is even worse. xml I can write multiline strings as a first class entity.

    I can add a comment to an xml document, json I have to write something hacky like "//": "my comment" and hope whatever is consuming it doesn’t care.

    there’s just as many problems with json parsers, since most but not all of them treat numbers as js numbers, which are basically floats. you can’t rely on an arbitrary consumer having support to parse ints above a certain size so you just have to make everything a string and hope.

    json allows duplicate keys, but they get overridden by the last occurrence. you can’t round trip json without losing something. you can’t rely on just seeing a key value in json text and that being correct since there could be another later. doesn’t come up often but it’s there.




  • idk if it will. it’s not adding scripting to documents(which already exists), it’s allowing a webpage that you’ve opened, that is already running code, embed a libreoffice document and control it.

    unless you’re uploading your documents to a webpage and it’s stealing them or something of that form, I don’t think there’s much if any new security threat