Git Product home page Git Product logo

Comments (8)

SethDavenport avatar SethDavenport commented on August 14, 2024

@bennett000 @yuri @winkerVSbecks @bertrandk @rbrander @andrejkn

from rangle-starter.

SethDavenport avatar SethDavenport commented on August 14, 2024

Current issues:

redux-react's connect typing won't accept a functional stateless component:

ERROR in ./src/containers/App.tsx
(73,3): error TS2345: Argument of type '({ children, session, login, logout }: { children: any; session: any; login: any; logout: any; })...' is not assignable to parameter of type 'typeof ElementClass'.
Type '({ children, session, login, logout }: { children: any; session: any; login: any; logout: any; })...' provides no match for the signature 'new (props?: any, context?: any): ElementClass'

from rangle-starter.

SethDavenport avatar SethDavenport commented on August 14, 2024

2: Same thing for reduxForm:

ERROR in ./src/components/LoginForm.tsx
(79,4): error TS2345: Argument of type '({
handleSubmit,
resetForm,
isPending,
hasError,
fields: {
username,
password,
...' is not assignable to parameter of type 'typeof ElementClass'.

from rangle-starter.

winkerVSbecks avatar winkerVSbecks commented on August 14, 2024

@SethDavenport official typings coming soon: reduxjs/redux#1413

from rangle-starter.

SethDavenport avatar SethDavenport commented on August 14, 2024

That's cool - I can work around (1) in the meantime by converting my containers to class components.

However redux-form typings have the same issue. I'm also expecting Radium to have it as well, although I haven't tried it yet. Actually not sure Radium even has typings...

from rangle-starter.

SethDavenport avatar SethDavenport commented on August 14, 2024

@winkerVSbecks - that PR is for redux, which is great. But I'm talking about connect() from react-redux.

  export function connect(mapStateToProps?: MapStateToProps,
                          mapDispatchToProps?: MapDispatchToPropsFunction|MapDispatchToPropsObject,
                          mergeProps?: MergeProps,
                          options?: Options): ClassDecorator;

We need an overload of this that doesn't return ClassDecorator, but rather something that can decorate StatelessComponent<P>

Might make a PR to DefinitelyTyped at some point.

from rangle-starter.

winkerVSbecks avatar winkerVSbecks commented on August 14, 2024

@SethDavenport yes, my bad. @bennett000 mentioned that DefinitelyTyped has kind of stalled at this point. Since, Redux is bringing typings into the main repo we should probably do the same for react-redux, etc.

from rangle-starter.

estaub avatar estaub commented on August 14, 2024

It would be good to include a pass-through property or two (properties provided by the parent component) in e.g. counter-page.tsx, since this takes a long time to puzzle out how to fix the first time. (For me, the solution was to create an IOwnProps interface for them:

interface IState  { tab: string }
interface IDispatch { onTabChange: (any)=>void }
interface IOwnProps { title:string }   
export class YnAppBarView extends Component<IState & IDispatch & IOwnProps, {}> {

... and then set it as ownProps on the connect:

const mapStateToProps =
    (state, props:IOwnProps)=>({
        myProp: state.yadayada      // e.g.
    })

but you may well have a better way to handle this!

from rangle-starter.

Related Issues (20)

Recommend Projects

  • React photo React

    A declarative, efficient, and flexible JavaScript library for building user interfaces.

  • Vue.js photo Vue.js

    🖖 Vue.js is a progressive, incrementally-adoptable JavaScript framework for building UI on the web.

  • Typescript photo Typescript

    TypeScript is a superset of JavaScript that compiles to clean JavaScript output.

  • TensorFlow photo TensorFlow

    An Open Source Machine Learning Framework for Everyone

  • Django photo Django

    The Web framework for perfectionists with deadlines.

  • D3 photo D3

    Bring data to life with SVG, Canvas and HTML. 📊📈🎉

Recommend Topics

  • javascript

    JavaScript (JS) is a lightweight interpreted programming language with first-class functions.

  • web

    Some thing interesting about web. New door for the world.

  • server

    A server is a program made to process requests and deliver data to clients.

  • Machine learning

    Machine learning is a way of modeling and interpreting data that allows a piece of software to respond intelligently.

  • Game

    Some thing interesting about game, make everyone happy.

Recommend Org

  • Facebook photo Facebook

    We are working to build community through open source technology. NB: members must have two-factor auth.

  • Microsoft photo Microsoft

    Open source projects and samples from Microsoft.

  • Google photo Google

    Google ❤️ Open Source for everyone.

  • D3 photo D3

    Data-Driven Documents codes.