diff options
author | Hayleigh Thompson <me@hayleigh.dev> | 2022-05-14 10:26:15 +0100 |
---|---|---|
committer | Hayleigh Thompson <me@hayleigh.dev> | 2022-05-14 10:26:15 +0100 |
commit | beab31ed70c81259cf4940232d7200d144d87e34 (patch) | |
tree | 7397b5b75b93a8c049485839642ca0a609747be3 /src/ffi.mjs | |
parent | 91ec4caad7fedff7859f5a695f977fb91e163e53 (diff) | |
download | lustre-beab31ed70c81259cf4940232d7200d144d87e34.tar.gz lustre-beab31ed70c81259cf4940232d7200d144d87e34.zip |
:sparkles: Create a special-case 'style' attribute because React is awkward.
Diffstat (limited to 'src/ffi.mjs')
-rw-r--r-- | src/ffi.mjs | 10 |
1 files changed, 8 insertions, 2 deletions
diff --git a/src/ffi.mjs b/src/ffi.mjs index 2352f01..89642c0 100644 --- a/src/ffi.mjs +++ b/src/ffi.mjs @@ -4,7 +4,7 @@ import * as Gleam from './gleam.mjs' // ----------------------------------------------------------------------------- -export const mount = ({ init, update, view }, selector) => { +export const mount = ({ init, update, render }, selector) => { const root = document.querySelector(selector) if (!root) { @@ -22,8 +22,12 @@ export const mount = ({ init, update, view }, selector) => { const App = React.createElement(() => { const [state, dispatch] = React.useReducer(update, init) + const el = render(state) - return view(state)(dispatch) + + return typeof el == 'string' + ? el + : el(dispatch) }) ReactDOM.render(App, root) @@ -108,4 +112,6 @@ export const map = (element, f) => (dispatch) => { // ----------------------------------------------------------------------------- +export const object = (entries) => Object.fromEntries(entries) + const capitalise = s => s && s[0].toUpperCase() + s.slice(1) |