Skip to content

Can't make unistore work with TypeScript #188

@Drarig29

Description

@Drarig29
class MyComponent extends Component {
    render() {
        return <p>{this.props.foo}</p>
    }
}

export const Comp = connect('foo')(MyComponent);

class App extends Component {
    render() {
        return <MyComponent />;
    }
}

interface AppState {
    foo: string
}

const initialState: AppState = {
    foo: "bar"
}

render(<Provider store={createStore(initialState)}><App /></Provider>, document.body);

I'm sorry but I couldn't find something which works in this scenario... I've been struggling with this basic thing for hours and I still can't understand how it works 😥

My needs are basic. I only need a global store, which holds the app's global state. But I don't need actions or anything fancy...
And I need every component to be class-based. Not functions, but you only have examples of that...

This code works in JSX, but when I want to use it in TSX, there is an error at the connect() line saying MyComponent is not of the good type.

Metadata

Metadata

Assignees

No one assigned

    Labels

    No labels
    No labels

    Projects

    No projects

    Milestone

    No milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions