Code Monkey home page Code Monkey logo

Comments (9)

Zaid-Ajaj avatar Zaid-Ajaj commented on July 19, 2024 2

Wow facepalm hahah, this worked like a charm! thanks a lot ❀️

from fable-react.

realvictorprm avatar realvictorprm commented on July 19, 2024 1

I'm going to add some notes.

from fable-react.

realvictorprm avatar realvictorprm commented on July 19, 2024 1

done

from fable-react.

alfonsogarciacaro avatar alfonsogarciacaro commented on July 19, 2024

It's funny that you asked that, because in Fable 1.x you can use a . to select a member when importing a value, like:

ofImport "Select.Creatable" "react-select" myOptions []

...but exactly right now I just removed it from Fable 2 because I thought nobody was using it πŸ˜…Can you give it a try and check if it works for you? If it does, I guess I should put it back in dev2.0 πŸ˜‰

from fable-react.

Zaid-Ajaj avatar Zaid-Ajaj commented on July 19, 2024

I tried just now it but it didn't work with my example and I am not sure why. I have this function:

let creatable (props: ICreatableProps list) = 
    ofImport "Select.Creatable"
             "react-select"
             (keyValueList CaseRules.LowerFirst props)
             [] 

I get runtime error: Cannot read property Creatable of undefined and also a compile warning export 'Select' was not found in 'react-select' which is weird because I have installed react-select correctly. Now even if I change Select.Creatable to Select I get the same warning . . . strange.

Anyways, if you are thinking of removing this pattern completely, their should be alternative way to do it because major UI frameworks (Elemental/Material/Semantic...) use this nesting to group elements.

I guess the reason no one is using this feature is because no one has tried yet to port these large frameworks.

from fable-react.

alfonsogarciacaro avatar alfonsogarciacaro commented on July 19, 2024

This is the usual confusion with JS imports πŸ˜‰ According to react-select README, it must be imported as follows:

import Select from 'react-select';

This is a default import (not a member import like import { Select } from 'react-select'). For this, in Fable you just have to write "default". Can you try the following?

let creatable (props: ICreatableProps list) = 
    ofImport "default.Creatable" "react-select"
             (keyValueList CaseRules.LowerFirst props)
             [] 

from fable-react.

alfonsogarciacaro avatar alfonsogarciacaro commented on July 19, 2024

Don't worry, I've made the same mistake thousands of times. Unfortunately, it's not something Fable can check at compile time :/ We need to make it more prominent in the docs.

Thanks for confirming it's working! I'll put back the feature in Fable 2 πŸ‘

from fable-react.

realvictorprm avatar realvictorprm commented on July 19, 2024

@alfonsogarciacaro would it be worth to note this somewhere on this repository? Aka a FAQ ;)

from fable-react.

alfonsogarciacaro avatar alfonsogarciacaro commented on July 19, 2024

@realvictorprm You're right. This feature is not documented, we should add it in the doc section talking about imports πŸ‘

from fable-react.

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.