ArthurClemens / polythene

Material Design component library for Mithril and React
590 stars 43 forks source link

Error: "The selector must be either a string or a component." #91

Closed modir closed 4 years ago

modir commented 4 years ago

I copy/pasted this code into my project.

import m from "mithril"
import { RadioGroup } from "polythene-mithril"

// Better solution
m(RadioGroup, {
  name: "company",
  buttons: [
    {
      value: "1",
      label: "One",
    },
    {
      value: "2",
      label: "Two",
    }
  ]
})

Now I get at the line m(RadioGroup, { the error message: Error: "The selector must be either a string or a component."

Isn't RadioGroup a component? Or what else I am doing wrong?

FYI: I am using mithril 2.0.4.

ArthurClemens commented 4 years ago

Perhaps you are not using a component around the RadioGroup? See this example: https://codesandbox.io/s/polythene-for-mithril-radiogroup-x8kwu

modir commented 4 years ago

There is a component around it:

                m(".inputgroup",
                    m(RadioGroup, {
                        name: "salutation",
                        onChange: state => {
                            vnode.state.checkedValue = state.target.value;
                            Customer.current.salutation = state.target.value;
                        },
                        buttons: [
                        {
                            value: "1",
                            label: "Herr",
                        },
                        {
                            value: "2",
                            label: "Frau",
                        },
                        {
                            value: "0",
                            label: "Firma",
                        }
                        ]
                    })
                ),

The whole form around it works if I leave the RadioGroup away. That's why I am surprised.

ArthurClemens commented 4 years ago

Updated codesandbox with your code: https://codesandbox.io/s/polythene-for-mithril-radiogroup-issue-91-w8x5e

modir commented 4 years ago

OK. I found the problem now. Initially I came from https://www.npmjs.com/package/polythene-mithril-radio-group Because of this page I only installed the radio-group package. But this package alone doesn't have all the needed components. Once I imported polythene-mithril all started to work. Maybe it would be good if you extend the documentation on npmjs.com and write there that always the full package is needed.

modir commented 4 years ago

Additional information: When only using the code mentioned on https://github.com/ArthurClemens/polythene/blob/master/docs/components/mithril/radio-button.md then the radio button icons appear wrong. Screenshot from 2020-05-06 17-22-36 In other words "polythene-css" is needed as well for a function set-up.