Manoj Sethi
Manoj Sethi

Reputation: 2038

React + Typescript : TypeScript error: Type 'string' has no properties in common with type 'CSSProperties'

I am using Typescript with React and is currently facing the issue

Error in Compiling

Upvotes: 24

Views: 32891

Answers (1)

Dylan Walker
Dylan Walker

Reputation: 1127

The style attribute expects an object with style properties rather than a string:

style={{
    backgroundImage: "url('https://source.unsplash.com/07fzqFEfLlo/1920x1080')"
}}

See the React docs on the subject.

Upvotes: 43

Related Questions