kibana/examples/routing_example/public
Anton Dosov 240c4ff15b
[react@18] More breaking type fixes (should be the last pr) (#192266)
## Summary

Part of https://github.com/elastic/kibana/issues/138222

in @types/react@18 types
https://github.com/DefinitelyTyped/DefinitelyTyped/pull/56210. This PR
addresses a bunch of remaining fixes **(hopefully the last mass ping PR
like this)** The most common are:


### 1 Objects are no longer considered a valid ReactNode

In types@17 the ReactNode typing was too soft, it allowed objects and
functions being passed as ReactNode, e.g.

```
let obj: React.ReactNode = {};
let func: React.ReactNode = () => {};
```

This was by mistake, and this PR mutes most of such cases by simply
casting to a `string` or `ReactNode`.
In some cases, it is worth to follow up and address the raised issues in
a better way (see in comments)


```diff

function MyComponent() {

const error: string | Error = 'Error'

return (
  <div>
-   {error}
+   {error as string}
  </div>
)

}

```


Most common problems are related to rendering errors, where it could be
`string | Error` object rendered directly as a ReactNode. Most often it
is related to alerting framework:

```
export interface RuleFormParamsErrors {
  [key: string]: string | string[] | RuleFormParamsErrors;
}
```

Not sure if there is a better fix then casting, surely not short-term. 

### 2 More `useCallback` implicit any fixes

Follow up to https://github.com/elastic/kibana/pull/191659

### 3 `EuiSelect` doesn't have a placeholder prop 

In a couple of places, the `placeholder` prop was removed. This is
because react types were updated and `placeholder` was removed from the
base HTML element, so it highlighted places where `placeholder` prop was
redundant
2024-09-12 13:54:18 +02:00
..
app.tsx Adds AGPL 3.0 license (#192025) 2024-09-06 19:02:41 -06:00
get_message_example.tsx Adds AGPL 3.0 license (#192025) 2024-09-06 19:02:41 -06:00
index.ts Adds AGPL 3.0 license (#192025) 2024-09-06 19:02:41 -06:00
plugin.tsx Adds AGPL 3.0 license (#192025) 2024-09-06 19:02:41 -06:00
post_message_example.tsx Adds AGPL 3.0 license (#192025) 2024-09-06 19:02:41 -06:00
random_number_between_example.tsx Adds AGPL 3.0 license (#192025) 2024-09-06 19:02:41 -06:00
random_number_example.tsx [react@18] More breaking type fixes (should be the last pr) (#192266) 2024-09-12 13:54:18 +02:00
services.ts Adds AGPL 3.0 license (#192025) 2024-09-06 19:02:41 -06:00