createUseStyles typescript declaration missing
See original GitHub issueSteps to reproduce:
- Create a fresh react app
npx create-react-app use-styles-ts
cd use-styles-ts
- Add react-jss and typescript
yarn add react-jss@next typescript
yarn add -D @types/react
- Rename
App.js -> App.tsx
and implement a simple usage ofcreateUseStyles
hook
import React from 'react';
import { createUseStyles } from 'react-jss';
const useStyles = createUseStyles({
App: { textAlign: 'center' },
})
function App() {
const classes = useStyles();
return (
<div className={classes.App}>
...
- Start app
yarn start
Expected behavior:
- App compiles and runs normally
Describe the bug:
- App fails to compile with error:
Failed to compile.
/Users/robcmills/src/jss-use-styles/src/App.tsx
TypeScript error in /Users/robcmills/src/jss-use-styles/src/App.tsx(2,10):
Module '"../../../../../Users/robcmills/src/jss-use-styles/node_modules/react-jss/src"' has no exported member 'createUseStyles'. TS2305
1 | import React from 'react';
> 2 | import { createUseStyles } from 'react-jss';
| ^
3 | import logo from './logo.svg';
4 | import './App.css';
- Apparently a typescript declaration for
createUseStyles
is missing fromreact-jss/src/index.d.ts
- I have confirmed that adding a declaration for
createUseStyles
to this file silences the error
Versions:
- react-jss: 10.0.0-alpha.17
- typescript: 3.5.2
- Browser [e.g. chrome, safari]: Chrome Version 74.0.3729.131 (Official Build) (64-bit)
- OS [e.g. Windows, macOS]: macOS Sierra version 10.12.6
Issue Analytics
- State:
- Created 4 years ago
- Comments:9 (4 by maintainers)
Top Results From Across the Web
TypeScript Typings with createUseStyles from react-jss
The main thing I believe was missing was having useTheme typed const theme = useTheme<PUTheme>();. View working Code Sandbox here! Share.
Read more >@types/jss | Yarn - Package Manager
This is a stub types definition. jss provides its own type definitions, so you do not need this installed. Stub TypeScript definitions entry...
Read more >JSS v10 - Oleg Isonen - Medium
So why do we need a hook creator function createUseStyles() that returns a hook function useStyles() ? It's because we want to automate...
Read more >jsstyles - Bountysource
Describe the bug: I'm creating a useStyles hook where the rules are all derived from prop values: const useStyles = createUseStyles({ styles: {...
Read more >Exploring CSS in JS - lee.david.cs
Many well-maintained CiJ libraries ship with TypeScript definitions (examples: Styled-Components, JSS, Emotion, Aphrodite).
Read more >Top Related Medium Post
No results found
Top Related StackOverflow Question
No results found
Troubleshoot Live Code
Lightrun enables developers to add logs, metrics and snapshots to live code - no restarts or redeploys required.
Start FreeTop Related Reddit Thread
No results found
Top Related Hackernoon Post
No results found
Top Related Tweet
No results found
Top Related Dev.to Post
No results found
Top Related Hashnode Post
No results found
Top GitHub Comments
Having the same issue, just wondering why the issue has been closed.
Any update on this?