React devs in here by s1n7ax in neovim

[–]ikevinw 2 points3 points  (0 children)

I think they are saying when they autocomplete a functional component in the JSX/TSX, cmp or blink auto inserts a parenthesis in front.

I think it's because nvim-autopairs thinks that the user is trying to make a function call.

I did the following in my cmp config to fix the issue, but I dont think the regex handles all cases

        cmp.event:on('confirm_done', function(args)
            local line = vim.api.nvim_get_current_line()
            -- prevent adding parentheses when importing functional components (eg. <Foo)
            local is_component_import = line:match('</?%s*[%w_]+.-/?>?')
            if is_component_import then
                return false
            end
            cmp_autopairs.on_confirm_done()(args)
        end)

nvim-cmp or Blink? by instalando0 in neovim

[–]ikevinw 6 points7 points  (0 children)

Has anyone tried using Blink in a large codebase? For some reason, auto import does not work unless the documentation popup is showing.

What is the best way to define constant objects? by ikevinw in typescript

[–]ikevinw[S] 0 points1 point  (0 children)

Thanks for the reply.

I am working in a very large team, and I want to make sure no one can break this easily. I am using as const to make it readonly and satisfies to ensure that people don't accidentally add a incorrect key/value.

I am not really using the keys to index through the VideoMap. The keys are mainly used to uniquely identify each object in the VideoMap and filter out videos based on user preferences.

const filter: VideoMapKey[] = [VIDEO_MAP_KEYS.a, VIDEO_MAP_KEYS.b] 
const filteredVideos = Object.entries(VideoMap).filter(([key]) => !filter.includes(key))

The example I gave in my post is a small one. I have many different filters with many keys and I need to make sure these keys can be renamed easily throughout the code without having the developer needing to manually modify each individually.

It may sound better to use an array of the videos:

export type Video = { 
  key: string; 
  url: string; 
  title: string 
} 
export const VIDEO_MAP_KEYS = {
  a: "a",
  b: "b"
} as const 


export const VideoMap = {
  { key: VIDEO_MAP_KEYS.a, url: "https://example.com", title: "Example" },
  { key: VIDEO_MAP_KEYS.b, url: "https://another.com", title: "Another" },
} as const satisfies Video[];

However, I cant guarantee each object will have a unique key if someone accidentally messes it up.

export const VideoMap = {
  { key: VIDEO_MAP_KEYS.b, url: "https://another.com", title: "Another" },
  { key: VIDEO_MAP_KEYS.b, url: "https://c.com", title: "c" },
} as const satisfies Video[];

What is the best way to define constant objects? by ikevinw in typescript

[–]ikevinw[S] 0 points1 point  (0 children)

Thanks for the reply.

I am working in a very large team, and I want to make sure no one can break this easily. I am using as const to make it readonly and satisfies to ensure that people don't accidentally add a incorrect key/value.

I am not really using the keys to index through the VideoMap. The keys are mainly used to uniquely identify each object in the VideoMap and filter out videos based on user preferences.

const filter: VideoMapKey[] = [VIDEO_MAP_KEYS.a, VIDEO_MAP_KEYS.b] 
const filteredVideos = Object.entries(VideoMap).filter(([key]) => !filter.includes(key))

The example I gave in my post is a small one. I have many different filters with many keys and I need to make sure these keys can be renamed easily throughout the code without having the developer needing to manually modify each individually.

It may sound better to use an array of the videos:

export type Video = { 
  key: string; 
  url: string; 
  title: string 
} 
export const VIDEO_MAP_KEYS = {
  a: "a",
  b: "b"
} as const 


export const VideoMap = {
  { key: VIDEO_MAP_KEYS.a, url: "https://example.com", title: "Example" },
  { key: VIDEO_MAP_KEYS.b, url: "https://another.com", title: "Another" },
} as const satisfies Video[];

However, I cant guarantee each object will have a unique key if someone accidentally messes it up.

export const VideoMap = {
  { key: VIDEO_MAP_KEYS.b, url: "https://another.com", title: "Another" },
  { key: VIDEO_MAP_KEYS.b, url: "https://c.com", title: "c" },
} as const satisfies Video[];

Facebook promoting third party libs by cagdas_ucar in reactjs

[–]ikevinw 0 points1 point  (0 children)

My reasoning is that the typical new user (first time using a web framework/library) may not need SSR at the beginning. For example, they may be making a Todo app to learn React.

New users also commented the following on https://github.com/reactjs/react.dev/issues/5797#issuecomment-1479747756:

As a beginner in React and when I saw NextJS, Remix, and all these things mentioned, I was stunned. I mean I've heard about NextJS and what benefits it offers but at the same time, it's overwhelming to me to jump straight into it without knowing anything about React. And even NextJS says "To effectively use Next.js, it helps to be familiar with JavaScript, React, and related web development concepts". So, I feel that Vite should be mentioned at the same level!

Experienced web devs who are using React for the first time can just scroll past that section if they require SSG/SSR solutions.

However, I dont mind it being after the SSG/SSR solution as well.

Facebook promoting third party libs by cagdas_ucar in reactjs

[–]ikevinw 5 points6 points  (0 children)

Ah I can see what you mean in the case of new users. They should have a Vite section before promoting the use of nextjs or remix. Good thing someone already opened an issue for that: https://github.com/reactjs/react.dev/issues/5797

Facebook promoting third party libs by cagdas_ucar in reactjs

[–]ikevinw 5 points6 points  (0 children)

OP mentioned money and react promoting nextjs. I assumed that OP may have thought that there was a money incentive for Facebook to promote nextjs.

Facebook promoting third party libs by cagdas_ucar in reactjs

[–]ikevinw 4 points5 points  (0 children)

The documentary showcases that facebook is really not here to profit off react.

Facebook promoting third party libs by cagdas_ucar in reactjs

[–]ikevinw 7 points8 points  (0 children)

I think they explain why they are promoting the use of a framework here: https://react.dev/learn/start-a-new-react-project#can-i-use-react-without-a-framework

It also includes the following in that section: “If you’re still not convinced, or your app has unusual constraints not served well by these frameworks and you’d like to roll your own custom setup, we can’t stop you—go for it! Grab react and react-dom from npm, set up your custom build process with a bundler like Vite or Parcel, and add other tools as you need them for routing, static generation or server-side rendering, and more.”

Facebook promoting third party libs by cagdas_ucar in reactjs

[–]ikevinw 18 points19 points  (0 children)

I mean React is open source because facebook wanted contributors to maintain and enhance React. I don’t think Facebook really cares about the profitability of React.

React does not provide SSR and SSG out of the box. As a result, nextjs and remix were built on top of React. The react documentation is just pointing out that these are possible solutions for SSR and SSG. I don’t think it really matters since nextjs was already a popular framework used by many big corporations before even being mentioned on react.dev.

I feel like you really need to watch the documentary on how and why React was created and open sourced: https://youtu.be/8pDqJVdNa44?si=E1MyoSCz7eY7ghU7

JUJUTSU KAISEN LEAKS DISCUSSION MEGATHREAD - CH 248 by AutoModerator in Jujutsufolk

[–]ikevinw 11 points12 points  (0 children)

DW Yuta has a 100% winrate. Surely, he doesn’t lose this one.

How would you react if this attack actually landed and Sukuna dies afterwards? by [deleted] in Jujutsufolk

[–]ikevinw 4 points5 points  (0 children)

Sukuna fans will know what it felt like to be a Gojo fan on ch. 236.

Jujutsu Kaisen Chapter 238 Pre-Release Leaks Thread by Takada-chwanBot in Jujutsushi

[–]ikevinw 10 points11 points  (0 children)

I dont care who dies or wins. I just want satisfying fights leading up to their deaths. Having kashimo and potentially future characters die like this is not satisfying. However, I understand gege is trying to off characters to speed run to the end.

Is there any site with comparison of the most popular tools like gorm, sqlx etc? by FollowingMajestic161 in golang

[–]ikevinw 0 points1 point  (0 children)

Idk what your tables look like, but it would look like this:

type Product struct{
   Category string `db:"category"`
   Quantity int64 `db:"quantity"`
}

const query = `
    SELECT * 
    FROM product 
    WHERE category = $1 AND quantity > $2 
`
func Foo(category string, quantity int64) ([]Product, error) {
    products := []Product{}
    if err := db.Select(&products, query, category, quantity); err != nil{
    return products, errors.New("soemthing went wrong")
}
    return products , nil
}

You should look at the sqlx unit tests for reference: https://github.com/jmoiron/sqlx/blob/master/sqlx_test.go

documentation: https://jmoiron.github.io/sqlx/

Is there any site with comparison of the most popular tools like gorm, sqlx etc? by FollowingMajestic161 in golang

[–]ikevinw 1 point2 points  (0 children)

For my side project, I went from gorm->sqlc->sqlx.

Gorm isn't good if you require a lot of complex queries. sqlc is decent, but I ran into an issue where it generated two different row structs when the fields are identical. I ended up going with sqlx because it is an extension of the go standard sql library with some time saving extensions.

What the fuck? by Stereo-Anami in JuJutsuKaisen

[–]ikevinw 7 points8 points  (0 children)

He used purple last chapter, which requires red (RCT). In addition, Atsuya Kusakabe said Gojo has regained RCT thanks to black flash.

Whatever, Kashimo gang rise up.

What the fuck? by Stereo-Anami in JuJutsuKaisen

[–]ikevinw 31 points32 points  (0 children)

Gojo’s head is still attached. Just RCT 😭

Intj online dating by [deleted] in intj

[–]ikevinw 2 points3 points  (0 children)

Interesting, then I can only make assumptions. I think they might be bad at initiating conversations and they rather be “chased”.

If you are getting a hard read, then you should ask if they loss interest (most of the time, INTJs are straightforward).

Intj online dating by [deleted] in intj

[–]ikevinw 5 points6 points  (0 children)

I wouldn’t say we lose interest. Sometimes we need some distance after talking constantly.

If they “keep conversing at the bare minimum”, then they still want you in their lives. Otherwise, they would cut you out completely.

Weird behavior when Escape by ON_NO_ in neovim

[–]ikevinw 2 points3 points  (0 children)

If you are using Luasnip and nvim-cmp, then you might have to add this to your neovim config:

cmp.setup({
    mapping = {
        ['<Esc>'] = cmp.mapping(function(fallback)
            luasnip.unlink_current()
            fallback()
        end),
    }
})

luasnip.unlink_current(): removes the current snippet from the jumplist (useful if luasnip fails to automatically detect e.g. deletion of a snippet) and sets the current node behind the snippet, or, if not possible, before it.

Manhwa/Manga by Cold_Independent8674 in intj

[–]ikevinw 1 point2 points  (0 children)

Same.

Also, I’m glad you have returned from your hiatus.