Like this:
function Component() {
const style = { "--my-css-var": 10 } as React.CSSProperties;
return <div style={style}>...</div>
}
Or without the extra style
variable:
function Component() {
return <div style={{ "--my-css-var": 10 } as React.CSSProperties} />
}
More Related Contents:
- Cannot use JSX unless the ‘–jsx’ flag is provided
- Default property value in React component using TypeScript
- How do I type this ‘as’ JSX attribute in TypeScript?
- Typescript + React/Redux: Property “XXX” does not exist on type ‘IntrinsicAttributes & IntrinsicClassAttributes
- Dynamic tag name in React JSX
- PropTypes in a TypeScript React Application
- How to use refs in React with Typescript
- React: Expected an assignment or function call and instead saw an expression
- What does the error “JSX element type ‘…’ does not have any construct or call signatures” mean?
- Property ‘value’ does not exist on type ‘Readonly’
- You should not use outside a
- Typescript image import
- Set loading state before and after an action in a React class component
- Set types on useState React Hook with TypeScript
- Visual studio code changes format (React-JSX)
- What does the colon mean in Javascript after function?
- React Hooks – Modified state not reflecting immediately
- React Hooks – Modified state not reflecting immediately
- Invalid configuration object. Webpack has been initialised using a configuration object that does not match the API schema
- React with Typescript — Generics while using React.forwardRef
- Warning: Prop `className` did not match. when using styled components with semantic-ui-react
- Passing object as props to jsx
- Disable ESLint that create-react-app provides
- React and TypeScript—which types for an Axios response?
- Create-React-App build – “Uncaught SyntaxError: Unexpected token
- Webpack & Typescript image import
- Property ‘value’ does not exist on type ‘never’. when use useRef hook in mui
- Only allow specific components as children in React and Typescript
- ‘React’ was used before it was defined
- Using styled-components with props and TypeScript