Code Monkey home page Code Monkey logo

Comments (4)

alfonsogarciacaro avatar alfonsogarciacaro commented on August 20, 2024 5

I can see two things here: first, according to the ReacTable docs you need a default import. See #60 (comment)

Second, IProp and friends are only used for builtin React elements: basically those representing HTML tags (div, input, etc). Other components define their own props, so you need to check the documentation and pass the props as a plain JS object. You can check here the different options to define JS objects in Fable.

I haven't tested it, but you should be able to initiate a ReactTable component with code similar to the following (from the ReactTable example):

open Fable.Core
open Fable.Core.JsInterop

// Helpers for dynamic typing
let inline (~%) x = createObj x
let inline (=>) k v = k ==> v

type [<Pojo>] Person =
    { name: string; age: int; friend: Person option }

let data =
    [| { name = "Tanner Linsley"
         age = 26
         friend = Some { name = "Jason Maurer"
                         age = 23
                         friend = None } } |]
let columns =
    [| %["Header" => "Name"
         "accessor" => "name"]
       %["Header" => "Age"
         "accessor" => "age"
         "Cell" => fun props -> span [Class "number"] [str !!props?value]]
       // Define other columns in a similar way
    |]

ofImport "default" "react-table" %["data"=>data; "columns"=>columns] []

from fable-react.

realvictorprm avatar realvictorprm commented on August 20, 2024 2

from fable-react.

realvictorprm avatar realvictorprm commented on August 20, 2024

@alfonsogarciacaro you're are a genius. Wow. Thank you so much, I've spend many hours today and you just solved the issue within a couple of minutes, amazing!

In short: Your example works instantly if a single change is applied, replace Class with ClassName.

PS: Yeah I finally can go on! 😄

from fable-react.

alfonsogarciacaro avatar alfonsogarciacaro commented on August 20, 2024

I'm no genius, I just happen to be the one who wrote the bindings ;) If anything, it means the API is not intuitive enough and we lack documentation. I'm a bit busy now with Fable 2, if you could write a post about importing external React elements with your experience it'd be great!

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.